SSH is one of those things I use every day, and maybe what I use most throughout the day. These are either things I didn’t know (escape sequences), or haven’t looked into before.
To get to the SSH escape sequences, you need a new line, followed by ~ and ?. That’s a newline (return), followed by a tilde and a question mark. This is what you get
Supported escape sequences: ~. - terminate connection (and any multiplexed sessions) ~B - send a BREAK to the remote system ~C - open a command line ~R - Request rekey (SSH protocol 2 only) ~^Z - suspend ssh ~# - list forwarded connections ~& - background ssh (when waiting for connections to terminate) ~? - this message ~~ - send the escape character by typing it twice (Note that escapes are only recognized immediately after newline.)
There are a lot of interesting things you can do with this. My favorite being if you ssh to host1.cainmanor.com then ssh to host2.cainmanor.com and then ssh to host3.cainmanor.com and host3.cainmanor.com locks up, you can newline ~~~. and the third session will be closed.
But wait!! There’s more
You can do some very nifty things in your ~/.ssh/config file. First, you’ve got to make sure you have very restrictive permissions on that file – 600 or bust.
Host nickname Hostname host1.cainmanor.com Port 22 User gcain ForwardAgent yes
Host – put a nickname you want here. You can use a wild card (*), if you’d like the apply the changes to all servers (for instance, change the port for all your servers)
Hostname – DNS name (FQDN highly recommended) or IP address.
Port – Port
user – user name you want to log in with.
You can also use this with rsync, but I won’t go too far into it.
rsync -avr --delete --exclude '.DS_Store' /share/MD0_DATA/Video/ firstname.lastname@example.org:/share/external/sdz1/Video/
rsync -avr --delete --exclude '.DS_Store' /share/MD0_DATA/Video/ nickname:/share/external/sdz1/Video/
Not as clear as a shorter example, but I wanted to keep this around for myself.