did you know that SSH has a little-known secret menu?

i wrote a post about this on cohost a while back, but since that site shut down i'm posting it here too

@rebane2001 @bert_hubert I wasn’t aware that there’s more than `~.` 🤯
@rebane2001
and of course the examples are my little pony references :D my hat's off to you.

@rebane2001

Yes, but did you know that it is basically inaccessible on Keyboard layouts like e.g. de-DE?

@rebane2001

Oh and if I recall correctly the keyboard combination is also different on macOS too...

@agowa338 @rebane2001 MacOS and Windows both have plain OpenSSH, and the listed escape sequences work on both.
@bob_zim @agowa338 @rebane2001 *if* your keyboard layout has a functioning tilde key (a deadkey might output something else and it's nontrivial to make it output just the character itself (and it depends on the OS how it deals with it))
@phl @bob_zim @agowa338 @rebane2001 For me, on a mac, hitting the deadkey and then space works. So, <Enter> ~ <Space> ? gets me to that menu.

@khrister @phl @bob_zim @rebane2001

Which makes it a different key combination and - well - try googling for it. I've literally never seen this being documented (in a discoverable way) anywhere.

@agowa338 Neither have I. Well, I somehow learned <Enter> ~ ^Z, not sure how. The rest I learned from this toot.

The ~ <space> trick I found out by trial and error, I think.

@phl Huh. I’m not sure I’ve seen a non-exotic (e.g, not for a Corne) layout which entirely lacks tilde as a discrete character. On my German keyboards, it’s on the AltGr layer of the +/* key. Same on Spanish QWERTY keyboards I’ve seen.

Not doubting that such a keyboard exists, I just thought I had seen most of the mass-produced layouts.

@bob_zim @phl

But the keyboard sequence becomes different and just trying to press it is annoying to impossible. Esp. if you then also try to do it over e.g an additional IPMI or VMware console in between as well.

It's just one of these things that feel like nobody expected anything but en-US being used as it just sucks. Almost always it is easier to first change your keyboard layout to en-US, press the keyboard shortcut, and switch it back...

@agowa338 @phl It doesn’t become a different sequence, though? Immediately after a new line, send a tilde character to signify the next character is a control character, then send the control character (e.g, ? to get the help and command line). Sure, you may press different keys to cause your keyboard to emit the tilde, but that doesn’t make it a different sequence. For example, nobody specifies Shift-/ in these sequences, they specify ?, and it’s up to you to get your keyboard to emit that character.

Yes, software trying to read scan codes directly and interpret them as US keyboards sucks, but that’s hardly the fault of applications like OpenSSH which do no such thing.

@bob_zim @agowa338 I think Klaus might have meant that depending on the layout the actual keys you have to press changes significantly (often not merely by location too)

I have absolutely no clue what I had to press on Hungarian keyboards for ^] in telnet, come to think of it XD I guess it wasn't what I think it was with my now mostly US-layout mind...

@phl @agowa338 Sure, but it’s the operator’s responsibility to know where characters are on the keyboard which they have. I’m currently switching to Colemak-DH on a split ergonomic keyboard, which has a totally custom layout for the non-alphanum keys (e.g, I have [ on the rightmost column of the left keyboard and ] on the leftmost column of the right). It wouldn’t be OpenSSH’s problem (or my OS’s or anybody but mine) if I didn’t give myself a way to type a tilde or if I forgot where it was.

@bob_zim @phl

Look, I'm not disagreeing with "the operator should know". However there at least should be some - easily discoverable, or even linked within "man ssh" - kind of documentation for where that combination gets mapped to on STANDARD keyboard layouts. Especially when it changes the entire sequence, not just location...

All I'm complaining about is the lack of documentation and how annoying it was especially when I first learned about that shortcut.

@bob_zim Hmm, tbf I'm not entirely sure if there's one with it missing (incidentally Spanish was the other layout I was suspicious of)... the deadkey aspect and it being hidden under layer 3 (and who knows if it's printed on the keyboard) definitely makes it more awkward and harder to type though than a Ctrl combination for example.

@phl By way of context, I used to work tech support for a vendor which sells Linux-based servers and which supported a bunch of applications which run on those servers on FreeBSD, Solaris, AIX, and a few other systems. I got calls from people all over the world, including people who had never really used a *NIX command line before, and had to walk them through filesystem operations and through using vim.

I remember dealing with at least seven different keyboard layouts more than once. JIS was a “fun” one because there are at least two wildly different layouts which people identify with that code. One has the tilde in the upper left like ANSI/ISO, the other has it two keys left of backspace.

@bob_zim The latter sounds suspiciously much like a Sun keyboard :D Esc to the left of 1?
@phl Left and up of 1, in the F row. Sometimes the 1 is extra wide and there is no key to its left.

@bob_zim ohh, right, that mode switch key is in the upper left.

I wonder just how many times my ISO trained hands would hit the ろ key instead of right shift if I ever had to use one of those things :D (I guess most other people think the same of the ISO 102nd key and left shift...)

@agowa338 @rebane2001 you can whine about it or you can read the manual and add EscapeChar to your ssh config to set it to any other character.

@gkrnours @rebane2001

I could do that If I'd only connect from one device to a hand full of other devices. But that just doesn't work when you're doing work for customers.

Configuring that would be even harder than getting the key combination changed within the OpenSSH source code for everyone...

@agowa338 @rebane2001 you can change the binding!

@draeath @rebane2001
See the other post, that'd be possible if I wasn't a consultant jumping hundreds of systems spread out across different customers. Sometimes even just for a few days or weeks in some projects. In my situation getting upstream to accept changing it would even be easier

Changing the binding on all of them or even just trying to find the ~ key itself is way more annoying than closing and reopening the terminal. Or when it is on a TTY switching to another and "killall -9 ssh".

@rebane2001
I learned about this escape feature during my Solaris sysadmin training in 2007, but never used it and had forgotten all about it.
@rebane2001 Always know that there is a key combination to close ssh connection
Also always forget what key is

@rebane2001 I'm forever annoyed that the command sequence starter is a newline of all things.

Telnet's UX was a lot better in this regard imo.

@rebane2001 I did!!!!! do I win anything?!?!?!
@rebane2001 yes. i just happened to look at the man page for it yesterday.

@rebane2001 Disabled by default on openssh *client* 9.2 and above.

https://github.com/openssh/openssh-portable/commit/f7cebbbf407d772ed71403d314343766782fe540

```
Host *
EnableEscapeCommandline yes
```
In your ssh_config file to re-enable it.

upstream: New EnableEscapeCommandline ssh_config(5) option · openssh/openssh-portable@f7cebbb

This option (default "no") controls whether the ~C escape is available. Turning it off by default means we will soon be able to use a stricter default pledge(2) in the client. feedback d...

GitHub
@baloo @rebane2001 that's only the command line (~c). the other escape sequences still work by default.
@baloo @mica @rebane2001 it’s a good security default. Imagine a bastion host or other program that allows you to ssh to a target host. The expectation is that all you can do is interact with the terminal on the target, or exit. However, the ssh escape allows you to create and delete tunnels, amongst other things, which might not have been anticipated. Disabling by default removes the surprise.
@baloo @rebane2001 That's only for the commandline you can get with `~C` , the rest is unaffected.

@rebane2001

I did not, but I am not surprised. I use ~^Z often, ~. sometimes, am old enough to remember ~ commands from mailx, and the ^] break in telnet.

@rebane2001 Yes, but unfortunately it is not available for multiplexed sessions 🥲
@rebane2001 stolen from the corpse of what was once a giant
@rebane2001 Isn't this just the nerdiest thing I've seen today.
@rebane2001 mind blown, thank you for sharing!
@rebane2001 I do enter tilde period A LOT and it’s a god send
@jsit @rebane2001 is there an equivalent, I wonder, for keyboards where tilde is not something you directly press? On some European keyboards ~ is a kind of diphthong key for: ã, õ etc. by typing the vowel after. The ~ character comes from pressing space after ~.
@rebane2001 It's actually the escapes that `cu` (part of the UUCP suite) implemented.
@stuartl
which may be the same as those of rsh (remote shell) which is the thing that ssh replaces.
@rebane2001

@rhialto @rebane2001 Could be, `cu` and `rsh` came out at the same time.

`tip` also has similar escapes, and it appeared in 4.2BSD (1983).

https://en.wikipedia.org/wiki/Tip_(Unix_utility)

tip (Unix utility) - Wikipedia

@rebane2001, it doesn't even have to be Enter as there's no keycode checking going on; Return, Ctrl-M and (not really all that surprisingly) Ctrl-J all work equally well.

It's not enabled here by default (OpenSSH on Devuan; see ssh_config(5)), but it's trivial to do per-session:
ssh -e'~' USER@HOST

I can even use ^] if I want to (to a small extent) mimic telnet, either as that pair of characters representing Ctrl-] or the actual character itself (inserted as a literal via e.g. the shell's quote key).

@rebane2001 Only problem is: I would only use it to look up how to terminate a hanged connection, because I always forget which weird shortcut that is -- but opening this help menu requires me to remember already half the keys from that shortcut. 🥲
@rebane2001 Hey why are you using my hostnames! /jk
@rebane2001 Did not know this, thanks :)
@rebane2001 I did know about terminating a session with ~. but the rest is good to know.

@Kurt For me, it's the most often use one. I used ~v today. :D

And I always forget about ~^Z, or use it without noticing what did I do. :D

@rebane2001 tnx that is nice to know!
You mean I don't have to do pkill ssh??
@rebane2001
I did not, this is neat