There's a whole bunch of other characters you can call prefixed with the Tilde (~) as well. My favorite is often ~^Z (That's tilde+Control-Z), which puts the SSH session in the background and drops you back to the host machine. You can hit ~? for a list. One other very, very useful one is ~#, which lists all forwarded connections - if you've setup X11 Forwarding or any port forwarding it lists the details for you.<p>Of course - if you're multihopping this all works as well. You'll need to add a ~ for each machine in the loop though.<p>E.g. if I hop from workstation -> server1 -> server 2... ~^Z drops me to workstation shell. ~~^Z drops me to server 1 shell.
Be careful if you're a couple sessions deep.<p>The proper way to kill a session if you're connecting from one server to another is ~~. (two tildes). Otherwise you'll kill your first session and lose access to the other session you connected to from it.<p>Also, as others have mentioned, <ENTER> first just to make sure you're on a new line.
On a related note, for folks using PuTTY.exe on Windoze to SSH, if you sometimes accidentally hit CTRL-S and "lock up" the session, hit CTRL-Q to recover.<p><i>Apparently CTRL+S actually does XOFF, which means the terminal will accept key strokes but won’t show the output of anything. It will appear as if your terminal is dead when it’s really just waiting to be turned back on. The fix? Simply press CTRL+Q to turn flow-control on (XON). If you pressed a whole bunch of keys before pressing CTRL+Q, you’ll see the output from those keystrokes.</i><p>credit: <a href="http://raamdev.com/recovering-from-ctrls-in-putty" rel="nofollow">http://raamdev.com/recovering-from-ctrls-in-putty</a>
This is why people on IRC always say things like:<p><pre><code> <jrockway> My net connectio*#$&*#^B^B^H~.~.~.
<jrockway> .~.
<jrockway> MY NET CONNECTION SUCKS
</code></pre>
Gotta have a newline before entering the escape sequence. Annoying when your session is not as dead as you think it is.
I've known about ~. as a way to end an ssh session for years. Unfortunately, it only works about 50% of the time. (It fails when the current session is piggy-backing on another session to the same host.)
for me this is a side effect often of starting something that hangs on to a standard in, out, or error. when starting server processes, it can be nice to do the full thing: nohup CMD > stdout.log 2> stderr.log < /dev/null &