Skip to content


SSH escape character

We sys admins are sometimes in situations where we have ssh connection to a server but want to do some other tasks on local computer, for example, copying a file to remote system without breaking the ssh connection. We can, of course, open a new terminal window and do the other task and then come back to ssh terminal but it is a lot easier and elegant way with ssh escape character.

The default escape character is ~. Say you have connected to a server Venus.

ssh testuser@venus
testuser@venus's password:

testuser@venus:~$

At this point you are connected to venus through ssh. Now you want to transfer a file to the same system but don’t want to break the current ssh session. Just press ~ (you wont see anything on th screen) and then CTRL+Z, the ssh session will be suspended. Do what you want and when you want to use that ssh session, type fg and press Enter (twice).

Some other escape sequences include

~.  - terminate connection
~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)
~~  - send the escape character by typing it twice

~C comes in handy if you want to do portforwarding but have already established a ssh session. Just press ~C and you have ssh command shell. Now you can use -Lport:host:hostport or -Rport:host:hostport. Interesting, isn’t it?

And finally ~? reveals all the options.

Share The Knowledge:
  • Print this article!
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • blogmarks
  • Diigo
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • Reddit
  • StumbleUpon
  • Twitter
  • Blogosphere News
  • Identi.ca
  • Slashdot
  • Technorati

Posted in Centos, Debian, Fedora, Red Hat, Ubuntu.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.