Ssh – How to track who SSH’es into the linux machine

logsSecurityssh

I'm running Ubuntu 10.04. Is there a way I can get a daily report of who has logged onto the box, what time, and even – this may be asking too much – a report of the commands they used? This is a low-usage box and so I think this would be a nice way to see what activity is happening on it.

Along these same lines, I heard it was not possible to track when things are done on the box via non-interactive shells, such as rsync or just remotely executing single commands via ssh. Is that true, or is there a way to log and track this as well?

Best Answer

The information of who logged in when is available in /var/log/auth.log (or other log files on other distributions). There are multiple log monitoring programs that can extract the information you configure as relevant. On any sane system, every user authentication is logged.

To log every command invocation (but not their arguments), use process accounting, provided by the acct package Install acct on Ubuntu. If the accounting subsystem is up and running, then lastcomm shows information about finished processes.

Related Question