TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to kill an unresponsive ssh session

122 pointsby iqueabout 15 years ago

12 comments

ritabout 15 years ago
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 -&#62; server1 -&#62; server 2... ~^Z drops me to workstation shell. ~~^Z drops me to server 1 shell.
oakenshieldabout 15 years ago
It's like people don't know about man pages anymore. Google is the man page... only you may not get your answer on the first try.
评论 #1298872 未加载
评论 #1298744 未加载
评论 #1298702 未加载
评论 #1298712 未加载
评论 #1298726 未加载
评论 #1298982 未加载
评论 #1299190 未加载
illumin8about 15 years ago
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, &#60;ENTER&#62; first just to make sure you're on a new line.
timmorganabout 15 years ago
I learn something wonderful almost every day on HN.<p>I just tried this, and it seems just ~. works fine (no newline needed).
评论 #1298719 未加载
jayliewabout 15 years ago
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>
jrockwayabout 15 years ago
This is why people on IRC always say things like:<p><pre><code> &#60;jrockway&#62; My net connectio*#$&#38;*#^B^B^H~.~.~. &#60;jrockway&#62; .~. &#60;jrockway&#62; 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.
pavel_lishinabout 15 years ago
Why is a Scandinavian asshole blocking the article?<p><a href="http://grab.by/42AG" rel="nofollow">http://grab.by/42AG</a>
评论 #1299760 未加载
评论 #1299137 未加载
Estragonabout 15 years ago
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.)
评论 #1300218 未加载
yesimahumanabout 15 years ago
Any chance these sessions are just on flow control and are actually not unresponsive (Ctrl-s/Ctrl-q)?
th0ma5about 15 years ago
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 &#62; stdout.log 2&#62; stderr.log &#60; /dev/null &#38;
hackermomabout 15 years ago
The SSHD - at least OpenSSH's - also kills mute sessions when it notices they have been completely silent for a while.
评论 #1298920 未加载
mmlabout 15 years ago
derp.