5 ms·
Pressing enter then ~. will gracefully shutdown hung ssh sessions
by SteveNuts 10y ago
Pressing enter then ~. will gracefully shutdown hung ssh sessions
- alfanick 10y agonice one, never seen that - always used ^D/exit
- wyldfire 10y agoThose are yet more graceful -- for when the shell is responsive. Use ~. in cases where for some reason you cannot get access to the terminal anymore but remote sshd is responsive.
- abstractbeliefs 10y agoiirc, enter-~-. isn't anything to do with the remote sshd. Instead, it escapes to the local ssh client (enter-~) that it should close (.). Which is really useful for if the remote sshd blew up, or, more commonly, your connection was broken.
- aji 10y ago~. (and the other ~ commands) are handled locally, not by the remote sshd. I use it when my network cuts out or something and my ssh session is unrecoverably stuck
- 0x0 10y agoActually the remote sshd does not need to be responsive, because "<cr>~." is interpreted by the local ssh client. Very convenient if the TCP connection is stuck. You can also type "<cr>~?" for a list of other commands supported by the local ssh client. Among other things, "<cr>~C" opens a command line interpreter on the client side of the ssh client, allowing you to add and remove TCP port forwarding without restarting the connection.
- Tyr42 10y agoAhg, I wish it let you scp files into your working directory too. That's be convenient.
- thomashabets2 10y agoLong ago I sent a patch for uploading downloading using this escape sequence, using zmodem like how an old windows SSH client (I forget the name) used to allow uploading/downloading files. You log in, type "rz<enter>", and then use escape sequence to upload a file. (similar for downloading) The patch was rejected. Shame. It's very useful when hopping 6 steps to upload a file.[1] I can't find the patch now, but I'm considering rewriting it as a an `expect` script. My `expect` scripts tend to have trouble with SIGWINCH propagation though, so not optimal. Also you have to remember to wrap with the `expect` script at (and preferably only at) the one "jump" you want to send from/to with the final destination. [1] No, nothing illegal. Just that some networks mandate SSH jumpgates, and sometimes multi-level.
- russb 10y agoYou can also layer the number of ~'s to skip over intermediary SSH sessions and send the escape to the proper one. \n~~. will escape the 2nd box you've SSH'd to, not the one it was originated from. Useful for escaping a screen'd SSH session that you might access through a jumphost.
- zingermc 10y agoI am amazed by the fact that I never accidentally trigger this feature.
- smhenderson 10y agoHah, yeah I seem to remember Ctrl-S leaving me flustered for quite a while when I first stumbled on it!
- gonvaled 10y ago^-Q is your friend!
- syncsynchalt 10y agoYes, it's a good choice of characters. Specifically, the escape sequence is "\n~", with various options (visible by typing "\n~?"), and if the option is unknown it passes the "\n~{x}" as-is. The biggest false positive you'll see is "\n~v", when executing bins out of the home dir of a user starting with the letter 'v'.
- makomk 10y agoYou'd probably trigger it more often if ~/ didn't conveniently map to ~/ - it's quite cleverly designed in a way. Indeed, most of the two-character combinations you're likely to type starting with ~ map to themselves.
- knorker 10y agoIt's annoying when you're adminning users and atually want to type "~user/foo" though.
- ChuckMcM 10y agoSadly it will shutdown only the 'outer' ssh session, so if you ssh to foo, and then from foo ssh to bar, and type ~. then the client->foo session is shut down but the foo->bar session is still around.
- grive 10y agoMore generally, type ~ as an escape sequence. For example, type ~^Z to put a session in the background. Similarly, type ~~ to send an escape sequence in an inner session, etc...
- qwertyuiop924 10y ago... There's a program called SSH to get to another CPU. Tilde is the escape, it's doubled to send it through, And "quit" is tilde-. I think you know how the rest goes...
- likeclockwork 10y agoWhat does this reference?
- lake99 10y agoI am not sure, but it looks vaguely familiar. There is a text-based game called adventure game called Dunnet where you come across a CPU card, and do some stuff with it later on. As far as I remember, the game predates SSH, so the game either had Telnet or FTP. My memory fades.
- qwertyuiop924 10y agoIt references "The TELNET Song" by Guy L. Steele (a.k.a The Great Quux). The original is about Telnet, and given the subject of discussion, the reference seemed a natural one to make.
- scubbojj 10y agoI don't - and in fact I finally got around to creating a HN account in order to ask you. Googling that just leads me back to this discussion. What's it from?
- qwertyuiop924 10y agoIt's parodying "the TELNET song," by Guy L. Steele.