I created a shell script that asks the connected user a question and after that it give him the prompt. The shell posts the question to a database for logging. The problem is that our developers are using a shared account, but each user has it's private key. Is there any way to read with the shell script (bash) what public key the connected user has?
There was a similar cuestion on Unix&Linux SE. With this in mind, you could grep the latest entry in your logs for the connecting IP:
Supposing you are using debian, sshd logs go to
auth.log
. If using an RH like distro they would be insecure.log
.You could raise the sshd logging level to VERBOSE by setting the LogLevel directive in
/etc/ssh/sshd_config
this causes sshd to log the following for each connection
The environment variable SSH_CONNECTION contains information oh the current connection
With a little bit of scripting it should be possible to pull the two together.