Telnet and SSH Escape Sequences

You are connected to a remote system thru Telnet/SSH. If Telnet/SSH session is suddenly went into a inaccessible mode, due to system failure or link disconnection or application failure, the Escape sequences will help us to quit from session immediately. Here I listed some of the Escape sequence supported by Telnet and SSH.

Pressing CTRL ] or ^], will give you the telnet command prompt (telnet>). In this prompt, you can try the following Escape commands:

  • ? — List all commands
  • close — Close current connection
  • logout — Forcibly logout remote user and close the connection
  • display — Display operating parameters
  • mode — Try to enter line or character mode (‘mode ?’ for more)
  • open — Connect to a site
  • quit — Exit telnet
  • send — Transmit special characters (‘send ?’ for more)
  • set — Set operating parameters (‘set ?’ for more)
  • unset — Unset operating parameters (‘unset ?’ for more)
  • status — Print status information
  • toggle — Toggle operating parameters (‘toggle ?’ for more)
  • slc — Set treatment of special characters
  • z — Suspend telnet
  • environ — Change environment variables (‘environ ?’ for more).

Pressing ~ and a Character combination will execute a particular escape sequence listed below:

  • ~. — Terminate connection (and any multiplexed sessions)
  • ~B — Send a BREAK to the remote system
  • ~C — Open a command line
  • ~R — Request rekey (SSH protocol 2 only)
  • ~^Z — Suspend SSH
  • ~# — List forwarded connections
  • ~& — Background SSH (when waiting for connections to terminate)
  • ~? — Show this list.
  • ~~ — Send the escape character by typing it twice.

Just assume, you are in System A and connected System C through System B like this A–> B–> C. Now the session B–> C is hanged. In this case, if you use the Escape sequence to disconnect the B–> C connection, then normally the session A–> B will be disconnected. Because, the Escape sequnce will processed by the 1st or outer session A–> B. So to pass the Escape sequence to 2nd or inner session B–> C, you have to use the ‘send’ command in Telnet and ‘~~’ sequence in SSH.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: