Log SSH connections with /etc/ssh/sshrc

categories:

Yannick over at http://blog.uggy.org always comes up with interesting and valuable tips.

Following his latest post regarding sshrc, I made my own sshrc script.

Unlike his example, I didn’t make SSH email me whenever a connection is made. That would be overkill given the number of connections I can make on a single day. Instead I’m just logging dates and IP in a log file of its own, which I plan on keeping forever.

My /etc/ssh/sshrc :

DATE=date “+%d.%m.%Y %Hh%Mm"IP=echo $SSH_CONNECTION | awk ‘{print $1}‘echo "$DATE - $IP" >> /var/log/ssh_connections.log




Thanks for reading this post!


Did you find an issue in this article?

- click on the following Github link
- log into Github with your account
- click on the line number containing the error
- click on the "..." button
- choose "Reference in new issue"
- add a title and your comment
- click "Submit new issue"

Your feedback is much appreciated! πŸ€œπŸΌπŸ€›πŸΌ

You can also drop me a line below!