0

I'm Ubuntu 18 user for some days. Previously I used Putty in Windows and it logs all my commands in SSH: Documents/Logs/2018-11-01_20-00-03_sshserver.log etc.

Now I need to setup logging in Ubuntu terminal too because I'm using terminal (putty doesn't know copy/paste to another app/window).

Can anybody tell me how to turn on logging?

Thank you very much.

  • When you do ssh A → B do you want to log the commands on A or on B? – PerlDuck Nov 23 '18 at 17:37
  • Want to log commands in my linux computer, no in server. So If I made a mistake in server, I will be able to see logs in my computer – Renik Nov 23 '18 at 19:46
  • with ssh user@server | tee -a log.txt you will have all output appended to a file called log.txt - but this logs all escape characters too, try it out and see if this satisfies your needs. – Zina Nov 23 '18 at 20:25
  • I'm connecting to 5-7 servers per day so I need automatically log everything. No way? – Renik Nov 23 '18 at 20:53
  • what do you mean with "putty doesn't know copy/paste to another app/window" ? haven't used putty on Ubuntu but I would assume it works like the Windows version. dont have a GUI version currently, only CLI so can't test. You can install putty on Ubuntu just sudo apt install -y putty – Zina Nov 24 '18 at 8:56
1

You could use the script command. Read man script.

script my.log
ssh A
    A stuff
    exit # on A
ssh B
    B stuff
    exit # on B
exit # end of script my.log
  • friends gave me this. What do you think? Using SSH for switches, mikrotik devices. If I connecting to servers I'm using ssh keys and passphrases. ssh_logging.sh #!/bin/bash script -f -c "ssh ${*}" "/home/rene/Documents/SSH-Logs/$(date '+%Y-%m-%d_%H-%M')_$1.log" ~/.bashrc alias ssh="/bin/bash ~/scripts/ssh/ssh_logging.sh" – Renik Nov 24 '18 at 21:35
  • Tis is not a code review site. This blob is unreadable in a comment. If you cannot figure it out don't do it – waltinator Nov 24 '18 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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