TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How to kill an unresponsive ssh session

122 点作者 ique大约 15 年前

12 条评论

rit大约 15 年前
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.
oakenshield大约 15 年前
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 未加载
illumin8大约 15 年前
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.
timmorgan大约 15 年前
I learn something wonderful almost every day on HN.<p>I just tried this, and it seems just ~. works fine (no newline needed).
评论 #1298719 未加载
jayliew大约 15 年前
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>
jrockway大约 15 年前
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_lishin大约 15 年前
Why is a Scandinavian asshole blocking the article?<p><a href="http://grab.by/42AG" rel="nofollow">http://grab.by/42AG</a>
评论 #1299760 未加载
评论 #1299137 未加载
Estragon大约 15 年前
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 未加载
yesimahuman大约 15 年前
Any chance these sessions are just on flow control and are actually not unresponsive (Ctrl-s/Ctrl-q)?
th0ma5大约 15 年前
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;
hackermom大约 15 年前
The SSHD - at least OpenSSH's - also kills mute sessions when it notices they have been completely silent for a while.
评论 #1298920 未加载
mml大约 15 年前
derp.