Portal Home > Knowledgebase > Articles Database > Log SSH Session to Email or File


Log SSH Session to Email or File




Posted by awells527, 07-26-2008, 08:24 PM
Hi, I'm wondering if it's possible to log all ssh commands to a file by session. For example, if I log in as user 'test123', once I close the session, all commands I ran will be saved to a file and either emailed to my server logs email address or saved to a file. Is this possible?

Posted by bluelion, 07-26-2008, 09:43 PM
Actually this should happen by default. If you use bash shell for example there is a file .bash_history in the home directory for a user that has the commands that have been typed in past shells. You can access the file by just typing the command "history". Once you exit gracefully from your shell the commands from that session are stored in the .bash_history file.

Posted by gpl24, 07-27-2008, 12:03 AM
But this history can be edited easily, can it not? I had somebody do a quick job on my server recently and when I looked at bash history, the time stamps were mixed up.. I can't help but think something was removed and then placed back (for whatever reason). I guess they didn't want me know the magic to their recipe and had second thoughts about it or something.

Posted by chaosuk, 07-27-2008, 05:14 PM
there are options available to you for this. Look at some keyloggers for example. But if your giving away permissions and then looking what was done, those too could be modified before you get the chance to look. I could probably write you a program that would send the logs offsite immediately if you required it badly enough.

Posted by awells527, 07-27-2008, 06:10 PM
It's nothing I urgently need, it's just something I thought of. I've had clients requesting shell access for some time now, and I will not provide it unless I know exactly what they are doing.

Posted by chaosuk, 07-27-2008, 06:20 PM
if you decide in future its something you would like to deploy, you know where to find me



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
API Required (Views: 253)