« Back to SSH

SSH escape sequences

Escape sequences are a patterns of keys that are recognized to send special instructions.

To see the ones that are supported, press tilde (~) followed by a question mark (?).

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.)

Important: you may need to press enter first before sending the escape sequence.

Terminate connection

When using a tilde followed by a dot, the connection will be closed. This is very helpful when your connection is stuck and no longer responds to CTRL+C. Especially connections are firewalls might encounter this issue, when the underlying network connection is terminated. The client can no longer send or receive data, so it gets stuck.

List forwarded connections

Using a tilde with a hash (#), the forwarded or open connections are displayed.

Example output:

The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 e[write]/4 fd 4/5/6 sock -1 cc -1 io 0x01/0x01)

Troubleshooting an active SSH session

Want to troubleshoot an active session? Then the tilde followed by a ‘v’ might help with more verbose output.

When pressing the combination, you may see output like

~v [LogLevel VERBOSE]

Once more and it will go to DEBUG, then DEBUG2, finally DEBUG3.


Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon