Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I searched a lot over the internet to complete this requirement, but didn't find a solution yet. So, please help me !!. Here is my requirement in short: I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    5

    Log all SSH commands at ssh-client


    Hello,

    I searched a lot over the internet to complete this requirement, but didn't find a solution yet. So, please help me !!.

    Here is my requirement in short:
    I just want to log all ssh commands at ssh-client machine that are being executed at the SSH server.

    In other words: I know a brief history of all executed commands on a linux machine can be retrieved from "bash history". I would like to get this info available also at the ssh-client machine (if possible, with more details like timestamps).

    I checked ssh-client configuration settings to see if it is possible to get those logs by modifying any variables. But, I didn't see anything there. By investigating more on this requirement, I guess it will be possible only if we do recompile SSH-client after modifying the code in order to log all the commands before handover it to ssh server.

    Any ideas?. Anyone has fulfilled a requirement like this?. Any help will be appreciated.

    Thanks in advance.

  2. #2
    Just Joined!
    Join Date
    Nov 2007
    Posts
    5
    Hi,

    At last I found a simple way to do this. Of course, it is not a good way, but useful to an extend.

    Try this:

    ssh user@server.com | tee -ai logfile.log

    This will log whatever you type on the server. The problem here is, "tee" will capture every inputs (it will capture even if you press arrow keys, backspace, tab key...... and will log it). So, if you open the log file you will see a lot of unreadable characters.

    Using commands like "strings" or "col -b" you can remove unwanted characters to an extend, but not fully. A solution what I found here is to use "cat" to view the log file. (using "tail" also looks fine).


    Regards,
    Mohammed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •