http://www.perlmonks.org?node_id=278819


in reply to Analyze Traffic of ssh port using perl script

To achieve that, you would probably need to configure your SSH server to write a logfile, and analyze that.

Also, the last and who Unix commands might be more useful for you.

Update: You might also want to take a look at the User::Utmp module.