How to kill an unresponsive ssh session
laszlo.nu
laszlo.nu
Of course - if you're multihopping this all works as well. You'll need to add a ~ for each machine in the loop though.
E.g. if I hop from workstation -> server1 -> server 2... ~^Z drops me to workstation shell. ~~^Z drops me to server 1 shell.
Then there are man pages that are actually being studied with great care, such as bash. And even bash man page is notorious for containing an endless amount of information. You can read it several times and still you will bump into a blog post or HN comment that reveals some previously missed (but documented) bash feature.
Telnet conveniently prints "Escape character is ^]" and that's why everybody knows it. I must admit it probably never occurred to me that ssh must have some sort of escaping method as well.
Well, thanks to HN for that link anyway :)
That said, reading the manpages for something that you use all the time like ssh is a good idea. (Though if you use zsh, I'll take a bit to go through all of the documentation)
The BSDs take man pages quite seriously.
I lost. It's a blog post about a documented feature. Tune in next week for the "-j" option to tar!
tar xf linux.tar.bz2
Brought to you by "A note from a random man page".And I certainly still find it useful, in any case, for situations where autodetection won't work -- for example when you are creating an archive. Y'know, with the "-c" flag that apparently you haven't read about yet.
Bazinga!
(edit: What I find most interesting isn't so much that you goofed your snipe, which happens all the time. It's that someone upvoted it.)
(not mine originally)
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.
Also, as others have mentioned, <ENTER> first just to make sure you're on a new line.
I just tried this, and it seems just ~. works fine (no newline needed).
"The escape character is only recognized at the beginning of a line."
so you'll generally need that newline to allow the escape to be detected, even though it's not technically part of the sequence.
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.
<jrockway> My net connectio*#$&*#^B^B^H~.~.~.
<jrockway> .~.
<jrockway> MY NET CONNECTION SUCKS
Gotta have a newline before entering the escape sequence. Annoying when your session is not as dead as you think it is.I have no idea about who Håkon Wium Lie is though. That must be some kind of misunderstanding.
Thanks for all the comments.
Great article btw.
Your distro likely enabled this, some enjoy messing with the sshd_config. (I believe Redhat and Redhat derived distros tend to enable this setting, but it is not the openssh default behavior.)