How can I track ssh sessions on my server including ssh connection time, disconnection time and idle time?

Here's what I have for connections:

cat /var/log/{auth.log,auth.log.1} | grep -i Accepted | sed "s/s*//g" | cut -d " " -f "1 3 4 5 12" | grep -v`

Currently I have to monitor tcptrack in order to track disconnections and idle time.


Have you checked the output of "last", maybe it would be sufficient?

server ~ $ last
root     pts/0      Fri Dec 11 10:35   still logged in
root     pts/0      Thu Dec 10 11:12 - 11:22  (00:09)
root     pts/0      Thu Dec 10 09:19 - 11:09  (01:50)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.