Record Your SSH SessionJanuary 30, 2013
If you’re troubleshooting an issue on your server and you suck at taking documention, you can simply pipe the SSH output into a file for review later:
ssh firstname.lastname@example.org | tee -a /path/to/file
What is really cool about this method (As opposed to just saving the history) is that it will also save the result of the command.
Last login: Wed Jan 30 10:19:44 2013 root@hydra [~]# echo "Hello" Hello root@hydra [~]# logout
You can also automate this. Create a file in your ~/bin/ directory called sshlog or similar and input the following code:
ssh [email protected] | tee -a /path/to/file
Set the execution bits and you can now run sshlog [email protected] and any other flags you would normally run with SSH and it will be appended to your file (as defined by the -a flag in tee). If you want this to always run when you kick of ssh, simply create an alias: