As part of our deployment script for one of our apps I'm trying to log the date, time, and other relevant information for the deployment.
The way we have it set up, developers use a generic "app" account to perform deployments, so logging the user wouldn't be particularly helpful.
Would it be possible to get the hostname of the machine that connected to the SSH session?
Best Answer
There's an environment variable you can look for called
SSH_CONNECTION
that gets set when you log in withssh
. If you want the hostname, you may need to do a reverse lookup withdig -x <ip address>
.From the man page: