News for hackers. Stuff that matters.
Re:SSH Escape Sequences by __david__ on Tuesday October 24, 2017 @03:07AM (#15539767)
Also remember that if you are sshing to a box (call it A) and then ssh-ing from there to another box (call it B) and you want to close the connection to B then you need to use "~~." SSH on your local computer will see "~~" and will send a single "~" to A. A will see "~." and close the connection to B.

Basically, however deep you are you need to send that many ~s before the period.

Re:SSH Escape Sequences by userbinator on Tuesday October 24, 2017 @06:30AM (#15540581)
Basically, however deep you are you need to send that many ~s before the period.

Isn't it exponential? To escape ~, you need ~~. To escape ~~, you need ~~~~. To escape ~~~~, you need ~~~~~~~~. Etc.

Re:SSH Escape Sequences by rootbear on Tuesday October 24, 2017 @09:35AM (#15541385)
The escape sequence for Telnet, however, was exponential. This lead to the Telnet Song, by Guy Steele, a link to which was once posted on HN.

https://news.ycombinator.com/item?id=2060597

Note that the "up arrow" referred to in the song is not the current up arrow on the cursor keypad. Some early versions of ASCII-ish had an up arrow where the caret is now. And telnet actually mostly used control-], not control-^ anyway. I seem to recall Steele saying that he used "up arrow" because it worked better in the lyrics. I heard Steele sing this once and I think I recorded it.

Re:SSH Escape Sequences by schoen on Tuesday October 24, 2017 @10:14AM (#15541667)
Thanks for that! Do you remember how many repetitions were used in your recording?
Re:SSH Escape Sequences by rootbear on Tuesday October 24, 2017 @10:27AM (#15541773)
I don't, but it's at least three, as I recall. Beyond that and you tend to lose your place and forget how many to sing.
Re:SSH Escape Sequences by kevhito on Tuesday October 24, 2017 @06:39AM (#15540618)
No, not exponential. The escape sequence is: <newline> then '~'. Anything after the '~' is special. In other words, only the first '~' appearing directly after a new line is special.

For example, <newline>~~~~ will send <newline>~~~ to the remote side.

Re:SSH Escape Sequences by barrkel on Tuesday October 24, 2017 @06:36AM (#15540606)
You need to enter ~ after pressing return (or else you have a bad time editing command lines involving home directories), so in practice only the first ~ each SSH instance sees needs escaping.
Re:SSH Escape Sequences by schoen on Tuesday October 24, 2017 @10:43AM (#15541902)
It's convenient there (and probably not accidental!) that Unix usernames are usually lowercase, so if you want to run a command like

~otheruser/bin/cat

it won't conflict with an ssh escape sequence (although you won't see the ~ appear until you've typed ~o).

On the other hand,

~Randomuser/bin/cat

would be impossible to type immediately at a new command prompt over an ssh connection (though of course it's possible to run such a command by typing anything such as "x<Backspace>" first).