I have a closed source program which calls server over ssh and executes set of commands. Could you tell me how can I log all commands? server is ubuntu

thank you

link|improve this question

75% accept rate
feedback

3 Answers

Snoopy can be used to log all commands ran on a system. Logs will be sent to syslog.

link|improve this answer
feedback

Without knowing exactly how it's doing it's thing, there's no one answer that I can give. However, a few possibilities:

  • It uses keys for authentication, and runs a command it passes at login: This is easy. Add a command= to the entry in ~/.ssh/authorized_keys that calls a script that logs the command it runs, and then just execs the command. Transparent, simple.
  • It uses keys for authentication, runs a shell, and stuffs commands down the shell: Harder, but still straightforward. Again, command= in ~/.ssh/authorized_keys to run a shell of your choosing, which could be something like sudoshell or something else that logs all commands (for super bonus trickery, you could even use script for full replayability).
  • It uses passwords: No command= trickery allowed here, you're going to have to go the whole hog and use something like snoopy to log everything that happens -- but unless this program is the only thing using SSH, you'll likely end up with a lot of logs.
link|improve this answer
the program can use key based auth. do you have script sample to log calls? thank you – user349302 Jul 5 '11 at 0:11
feedback

If the close source program allows you to edit remote ssh paramters or you can put the commands into a shell script, you can wrap your execution around the "script" command on the remote server:

ssh 192.168.15.200 'script ps.log -c "ps -ef"'

In this case, the output of ps -ef is saved into the file ps.log

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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