I've been using the ~. shortcut for a while, but somehow escaped learning about the help menu.
Another neat thing I noticed while playing with it just now: there's an option to enter ~ twice to send a literal ~, but usually you don't have to do this when typing something like 'ls ~' in a regular session. Not only does the ~ have to be the first character on a line to start an escape sequence, but typing on a line, backspacing all the way to the start and then typing ~ also sends a literal tilde. It only triggers the escape sequence if the ~ is the chronologically first character after a newline (or first in the session), which is an unlikely thing to type into a shell in a normal session. Good choice of UI, both the character and the state machine.
I've been using SSH for ~15 years and never knew about these escape sequences. I'm eagerly awaiting my next hung session so that I can test `~.`. It's much nicer than my current approach of having to close that terminal window.
I've used ~. for a long time but did not know about others. I know, should have read man page.
Anyway, if you try it from shell prompt it is likely will not work as pressing ENTER shows the next prompt. Try `cat` followed by ENTER and then ~?
The ~ (tilde) escape character in UNIX cu (call UNIX) did the same thing in the 1970s, when the remote system was on the other side of a telephone modem or other serial port. I think it's safe to say that ssh is a descendant of cu. (I don't mean that cu printed a help menu, I mean it had the tilde escape.)
Those aren’t “secret”, they’re obviously borrowed from rsh — oh that’s right, I’m old.
This is not specific to ssh. Telnet and rlogin have similar things with ~ as the escape character. Back in the day it was common to send BREAK and other escape sequences when you were hardwired.
I've had to use [Enter] ~. in SSH sessions before. I've had SSH/network get stuck and using that was the only way to kill the session (and recover).
I guess you could call it a "secret" or at least "not super-well known (to people who aren't Linux 'experts')."
it starts with a pretty common char, but almost never gets in the way to the point I forget it exists. Meanwhile docker -t uses ^P which I use all the time for history instead of arrow keys. It's possible to configure it, but it's not worth the hassle on servers. Really, really annoying.
I have set up Ctrl+k to kill (SIGKILL) the front process in my terminal. I just use that for hanging connections and other hanging processes.
Yep the menu is handy for ssh tunneling. Maybe not a lot of people doing that these days though with stuff like dev tunnels and Tailscale.
The ControlMaster mention deserves a full config block since the defaults make it awkward:
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h:%p
ControlPersist 10m
`mkdir -p ~/.ssh/sockets` first. With this setup, every subsequent ssh/scp/rsync to the same host reuses the existing master connection — no re-auth, near-instant open. ControlPersist keeps the socket alive for 10 minutes after the last session closes, so short gaps don't force a new handshake.This pairs well with the ~C escape discussed here: adding a port forward mid-session via ~C -L 8080:localhost:8080 doesn't require a new connection or re-authentication when a ControlMaster is already running. Useful for those "I need to tunnel something I didn't anticipate" moments.
What I thought I wanted: a way for Konsole to send SIGHUP
What I now have: ~B
What I really need: a way to stop long-running SSH connections from freezing
BRB requesting access to my remote server "animal style"
Wow, never knew this... That said I'm not sure if I'll remember using it as my muscle memory is already trained to kill hung processes via ctrl-b s, ctrl-k, ctrl-b x (in tmux).
This is a secret? I've had this baked into my muscle memory for decades when an SSH session hangs.
My gosh... I've spent decades closing a connection by killing the terminal.
~.
consider me one of the lucky 10000 . Used ssh for years, didn't know this!
Don't tell people this. In a minute you'll realize that this menu can only mean that ssh runs multiple channels, and so you can start up other things over an established ssh connection. Then the firewall guys will realize that they really can't allow ssh ... let's just not go there. Working at a bank is annoying enough already.
Secret Menu -> Escape Characters
I really hate it when people just rename terms. It made it harder to search properly for better answers.
You think that one is cool, go check out "~?" in IPMI "sol activate". From there you can deliver a serial break to the kernel, which then gets you to a third rarely seen menu from the kernel's console, which allows you to do kernel debugging of various sorts.
I use it when I need to crash a kernel on purpose to test kdump over the network.
You can also send commands to the simulated console of a VM under libvirt with "virsh connect". But I don't think you can send a break to the kernel with that.
Sometimes things feel so simple that i dont even read the manual. cool
FYI, you can kill forwarding tunnels with -KD portnum in that commandline too.
That doesn't do much good if you set `EscapeChar` to `none` in `.ssh/config`.
I find it convenient not to have to worry about accidentally entering escape characters. YMMV.
Find the HIDDEN SECRETS that THEY DON'T WANT YOU TO KNOW!
$ man ssh[dead]
Hidden or undocumented features like this always have a strange appeal. Part of it is nostalgia for older software where small Easter eggs or experimental features would sometimes ship in production builds.
I intended to post in defense of manpages. I love manpages. I think most open-source manpages are high-quality, and a few are really outstanding.
"It's easier to ask an AI" can be true without implying that manpages are bad.
However, "man" the tool does have issues, and one of them bit me just now.
So, I didn't know about openssh client escapes like ~?. I thought, "surely that's in the manpage?" I opened the manpage (in less) and searched for "\~\?". No hits.
Of course, escape characters are documented in the manpage, and the string "~?" does appear. Why didn't search find it? Because man, in its infinite wisdom, decided to render every instance of "~" as some bizarre unicode not-tilde, which is visually similar but totally impossible to grep for.
This has also bitten me in the past with dash. DASH. A character that is critically important when documenting invocation options. man loves to convert it into something that looks like dash, prints like dash, but doesn't come up in search.
I'm sure there is a way to turn this "feature" off, and I'm about to spend a bunch of time figuring out what it is. But this is documentation for command-line tools. Silently destroying our ability to grep it should NOT be the default.