News for hackers. Stuff that matters.
Re:The text adventure game of exiting a Telnet session by derpsabert on Friday January 31, 2020 @11:15AM (#22202807)
One of the many reasons why SSH is superior. Hit ~. and you're out.
Re:The text adventure game of exiting a Telnet session by jerf on Friday January 31, 2020 @11:27AM (#22202912)
For those who don't know about this, that's close, but a newline needs to precede the tilde: See https://linux.die.net/man/1/ssh and use browser find for "Escape Characters". I find this is one of those things that can pleasantly surprise people who have been using SSH for years without knowing about it. (Another one I see a lot is using the "authorized keys" to limit what command can be run with a particular key.)

(Along with the utility of force-closing connections, this is also why it can be surprisingly difficult to use SSH in situations where you want a low-privilege user to be able to access the shell of a remote system, but not immediately get up to crazy network shenanigans. SSH is actually too feature-rich for that use case, and this escape-character menu is an example of why; even if you somehow take control of the command line entirely, they can still start opening reverse forwards and doing a variety of other things. Very useful for reasonably privileged users, though.)

Re:The text adventure game of exiting a Telnet session by JdeBP on Friday January 31, 2020 @07:12PM (#22207365)
The old rlogin manuals are better than the OpenSSH manual in this regard.

* https://unix.stackexchange.com/a/454228/5132

Re:The text adventure game of exiting a Telnet session by raziel2p on Friday January 31, 2020 @11:40AM (#22203052)
The tilde character can be surpisingly hard to type on some keyboards as well. I can't even figure out how to do it on my current keyboard because in place of the backtick/tilde key is the escape key. On a norwegian keyboard the tilde character is "dead", meaning you have to press the tilde character followed by spacebar to get it, and that might not work in situations like wanting to exit an SSH session due to... reasons.
Re:The text adventure game of exiting a Telnet session by mprovost on Friday January 31, 2020 @03:52PM (#22205588)
The tilde escape predates SSH - it comes from the cu (Call UNIX) program in BSD 4.2:

https://github.com/dspinellis/unix-history-repo/blob/usr/src...

Re:The text adventure game of exiting a Telnet session by ASalazarMX on Friday January 31, 2020 @02:10PM (#22204561)
I just use the gold old ^D in an empty prompt.

https://en.wikipedia.org/wiki/End-of-Transmission_character#...

Re:The text adventure game of exiting a Telnet session by derefr on Friday January 31, 2020 @03:40PM (#22205449)
That's how you gracefully shut down an SSH session, with the socket close initiated from the remote end (where the shell is running.)

\n~. is for gracefully exiting a stuck/hung SSH session (e.g. one where the remote isn't responding to input) without force-killing the SSH client itself (which might do bad things to the process group it lives in.)

Re:The text adventure game of exiting a Telnet session by CamperBob2 on Friday January 31, 2020 @06:16PM (#22206972)
Unfortunately not all Telnet servers support that.

Being the least interesting programmer on Hacker News, I don't always write code to handle Telnet-compatible ASCII input, but when I do, I always support ^D.

Re:The text adventure game of exiting a Telnet session by aaubry on Monday February 03, 2020 @04:47AM (#22222776)
On portuguese keyboards, ~ is a dead key. You have to type ~<space>.<enter> I'm not sure whether that's superior.
Re:The text adventure game of exiting a Telnet session by ebg13 on Friday January 31, 2020 @11:27AM (#22202910)
Where do you see ~ on the AZERTY keyboard shown in the article?
Re:The text adventure game of exiting a Telnet session by zamadatix on Friday January 31, 2020 @11:29AM (#22202931)
How is ~. supposed to be superior
Re:The text adventure game of exiting a Telnet session by tyingq on Friday January 31, 2020 @11:36AM (#22203011)
You can set the telnet escape character via "telnet -e <char>".