One nifty feature of ssh that I sometimes forget to take advantage of is that you can use it to execute commands on a remote server and then promptly log you back out. Say for example that I would like to log onto a remote machine just to check the tail output of some log file. Instead of running ssh to log in, executing the command manually, and the logging back out; the whole operation can be performed as:
ssh myname@myhost ‘tail /path/to/logfile’
Inside of the single quotes is the command to execute. For programs that are user-interactive, such as top, you can pass the -t flag to ssh. I didn’t know this before, I found out today while reading systemsboy’s blog
ssh -t myname@myhost ‘top’
With this newfound ssh knowledge, I decided to put it to work by building some server control scripts. I now have scripts to shutdown, and restart my server which I can execute from my laptop