I would like to know how i could log SSH command lines a user is using on a server. For exemple, if the user Alex on my server is doing the following set of commands :
$ cd /tmp $ touch myfile $ ssh firstname.lastname@example.org $ ssh email@example.com $ vim anotherfile $ ssh firstname.lastname@example.org
I would like to log the ssh commands used on the server in a file which looks like :
[2014-07-25 10:10:10] Alex : ssh email@example.com [2014-07-25 10:18:20] Alex : ssh firstname.lastname@example.org [2014-07-25 11:15:10] Alex : ssh email@example.com
I don't care what he did during his ssh session, i just want to know WHEN and TO WHERE he made a connection to another server.
The user is not using bash and i would like to avoid manipulating .bash_history anyway as the user can modify it.
Any clue on this ?
Thank you :)
edit : to be more specific :
a user connects to a server A and then connects from the server A to server B. I want to track down to which server he connects through ssh from server A.