Read the SSH man pages every so often, even if you think you know how to use it. There's a lot of features in there. Don't miss the "AUTHORIZED_KEYS FILE FORMAT" in sshd's man page for the uber-cool "command='command'" options for authorized keys (restricts a given key to just be able to run a certain command, very useful). See also SSH's port forwarding, -D, learn how to use ssh-agent, and "man ssh_config".
Or use mosh[1] on top of SSH and stop worrying about that stuff.<p>It works much better over high-latency links (mobile). It is not bothered by saturated links, tolerates IP changes and losing the underlying connection like when you suspend your laptop and take it elsewhere.<p>I now have mosh connect to several servers in tabs when I run gnome-terminal the first time, and only disconnect on reboot. I also run a mosh-capable Irssi Connectbot fork on the phone[2].<p>It's a massive improvement, fixing many of the little annoyances of ssh.<p>[1] <a href="http://mosh.mit.edu/" rel="nofollow">http://mosh.mit.edu/</a><p>[2] <a href="http://dan.drown.org/android/mosh/" rel="nofollow">http://dan.drown.org/android/mosh/</a>
The default escape character ~ does not work if the tilde key in your keyboard layout is a dead key [1], like it is in many European layouts. It can be changed via the EscapeChar config option or the -e command line parameter. It seems, though, that not just any old character is accepted - I tried to use §, which, in the Finnish layout, is in the same physical position as ~ is in the US version, but ssh complains about "bad escape character".<p>EDIT - I suppose it must be an ASCII character, which is not an entirely unreasonable requirement.<p>[1] <a href="http://en.wikipedia.org/wiki/Dead_key" rel="nofollow">http://en.wikipedia.org/wiki/Dead_key</a>
enter-tilde-dot<p>It is useful, yes. Here's another thing I picked up last week - how do you reboot a remote linux box that's somehow lost its root drive but you still have a shell open (because you left ssh running on another machine)?<p><pre><code> echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger</code></pre>
Another useful trick to remember if you're using Putty and you ever accidentally hit Ctrl-S and find that you've frozen the terminal.<p>Just type Ctrl-Q and you will unfreeze the connection.<p>Credit due to: <a href="http://raamdev.com/2007/recovering-from-ctrls-in-putty/" rel="nofollow">http://raamdev.com/2007/recovering-from-ctrls-in-putty/</a>
<enter>~Ctrl-Z will suspend the ssh session, too.<p>I've also found it useful to do <enter>~C - then you can configure port forwarding without having to open a new ssh session.<p>(~C opens a command line, enter "help" for available commands.)
Please don't let HN become a substitute for RTFM. This should be known by all SSH users who have skimmed the man page. Fair enough as a blog post but for this trivia to get 46 points so far is deeply depressing.<p>Maybe I should write a blog post about the use of CTRL-Z in the shell and post that here, should get me Kilo-karma points if this is anything to go by.
If you happen to be a few sessions deep, ~~ will send ~ to the next session along. A casual ~~~~~~~~~~~. or so later and everything is wonderful again!
I'm a little surprised this is on HN? To me this is the equivalent of a blog post about using %d with printf.<p>Not complaining, just a little surprised something so novice would get attention...
While I've frequently used this to kill connections, my favorite thing I've done with it is to list existing and dynamically add new forwarding ports through SSH.
Hitting '.' at a prompt used to be a common idiom for exiting a program. I first saw it when I was a kid working on an HP-3000 system where the system programming language was BASIC and all programs followed this convention. Don't know where it came from originally, but you can still see it in places like rsh/SSH etc.
On a side note, does anyone know what ~B actually does? Does it send a SIGINT to the remote terminal? What does ssh mean by the phrase "send a BREAK to a remote system"?<p>I've tried to use it without success to kill a runaway listing of megabytes of scrolling text, but frantically hitting ctrl-C seems to work much better.