Possible Duplicate:
How can I break away from an SSH session that has crashed?

I have started an SSH session on the command line, but now I want to get back to my local command line. For any other process, I would hit Ctrl+Z, then run bg. However, the Ctrl+Z get's sent to the remote, rather than the local SSH process. How do I send it to the local SSH process?

  • I've found the answer elsewhere, but not until I'd searched for a while. Jul 5, 2012 at 11:18

2 Answers 2


There is escape char in ssh, by default this is tilde ~. It is recognized only after Enter.

To suspend your ssh session type ~ then Ctrl+Z.

Refer to the ssh(1) manual under ESCAPE CHARACTERS for more information.

  • note: ^Z escape not available to multiplexed sessions (connect via controlpath option)
    – yurenchen
    Oct 4, 2022 at 18:05

Maybe of less value nowadays, but in my $HOME/.bashrc I aliased ssh to

alias ssh='ssh -e ^]'

That way I avoid potential conflict with ordinary ~ usage albeit fresh after a newline. Instead, to escape out of an ssh session, I press Ctrl ] then Ctrl Z, which coincides with the way we used to do it under old telnet, long ago (or still on some embedded Linux devices, TVs etc. that don't have sshd).

Not the answer you're looking for? Browse other questions tagged .