2

Is there a way I can log my logins on the remote machine when I SSH in to said remote machine? Though I'd only occasionally have a use for this, there are times when it'd be pretty handy (e.g. scp'ing a file back to my local machine, when the remote path is particularly long)?

The machine(s) in question are running Ubuntu.

3 Answers 3

2

You may find last -a useful for this. Your accesses will also be logged in /var/log/auth.log (but by IP).

1
  • You can use nslookup or host to lookup the domain name of the IP address. Oct 31, 2010 at 14:27
1
whitequark@hagalaz:~$ ssh dagaz
Linux dagaz 2.6.26-2-686 #1 SMP Thu Sep 16 19:35:51 UTC 2010 i686
<skip>
whitequark@dagaz:~$ env | grep SSH
SSH_CLIENT=192.168.2.198 38427 22
SSH_TTY=/dev/pts/1
SSH_AUTH_SOCK=/tmp/ssh-omfqnn7365/agent.7365
SSH_CONNECTION=192.168.2.198 38427 192.168.2.10 22
whitequark@dagaz:~$

The host can be extracted with following bashism:

$ echo ${SSH_CLIENT%% *}
192.168.2.198

or using sed, if you like:

$ sed -e "s/ .*$//" <<<$SSH_CLIENT
192.168.2.198
0

Try who am i though i don't have a machine to test from. I often use this to set DISPLAY.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .