In the Windows world, I configure putty to log all of my sessions for a variety of reasons. When on a linux client, Putty isn’t a decent solution anymore, so I started exploring how to replicate this functionality. Google indicated the “script” command is what I was looking for.
However, the script command by itself would require quite a bit of extra typing to pass the ssh command and the log directory. Here is a simple bash script to make it seamless.
#!/bin/bash #Usage: ssh-logging.sh <hostname> #<hostname> can be in the form of user@host script -q -e -c "ssh $1" /home/jon/ownCloud/ssh-logs/$1-`date +%F-%T`.log
I made an alias for ssh to this script, but you could easily call it directly.
There are lots of things that could be done to improve its usage. Accepting more arguments for SSH, making it more modular in setting variables, etc. etc. This is good enough for my purposes.