Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

All, I have an Ubuntu host that accepts SSH connections. How can I log all commands that are run on a specific account that logs in via SSH?

Thanks

share|improve this question

4 Answers 4

Maybe you can make sshd use a logging shell like rootsh?

share|improve this answer
    
how do you install rootsh on Ubuntu –  Lexicon Mar 14 '12 at 20:14
    
@Lexicon: AFAIK there's no already-compiled deb package available, just a source archive. Installing an application from source is described here, for example. The INSTALL file located in the source archive describes the different config options you can set before compiling it. –  tohuwawohu Mar 14 '12 at 21:46

You can try with snoopy. After you install it, will logs all input command that calls execve to syslog. you'll only find it in the repos for hardy and precise.

You can install it from here.

share|improve this answer

I don't think SSHD logs commands while the user is logged in.

you can check who logged in by checking

/var/log/auth.log

and cross reference it to their history

/home/sshuser/.bash_history

history will have commands local or remote though.

share|improve this answer
1  
auth.log contains session opened and closed info but not commands that were ran while logged in. .Bash_history only show local commands, nothing through the ssh session (at least from what I can tell). –  Lexicon Mar 14 '12 at 14:38
    
~/.bash_history will not work as the user can alter the file. –  bodhi.zazen Mar 14 '12 at 17:19
    
.bash_history is not showing what happens via ssh. –  Lexicon Mar 22 '12 at 15:35

I have a similar problem and wrote the tool log-user-session which stores all shell output into a root-only accessible session log file. It can be enabled via forced command on sshd_conf or ~/.ssh/authorized keys (see documentation).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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