SSH Escape Sequence: ~.
A while back I was using ipmitool and Serial-over-LAN for some serial console access to remote servers. This involved tunnelling through multiple SSH sessions, then connecting over serial via ipmitool.
While you can’t Ctrl+D out of an ipmitool session – which is how I usually terminate an SSH session – ipmitool does support SSH escape sequences:
Supported escape sequences: ~. - terminate connection (and any multiplexed sessions) ~B - send a BREAK to the remote system ~C - open a command line ~R - request rekey ~V/v - decrease/increase verbosity (LogLevel) ~^Z - suspend ssh ~# - list forwarded connections ~& - background ssh (when waiting for connections to terminate) ~? - this message ~~ - send the escape character by typing it twice (Note that escapes are only recognized immediately after newline.)
However, issuing a
~. dumped me back out to my local machine! Not ideal.
I now know this is the standard behaviour of this escape sequence for any SSH session, but I only wanted to terminate the current ipmitool session, not my entire SSH tunnel.
The solution? Add extra
Specifically, add as many
~’s as SSH sessions you’ve started in order to go back one session. If you’ve had to SSH three times,
~~~. will dump you back to your second session – one session back.
~. Back to localhost ~~. Back to first SSH session ~~~. Back to second SSH session ~~~~. Back to third SSH session