Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
I've found the answer elsewhere, but not until I'd searched for a while. – Alex Chamberlain Jul 5 '12 at 11:18

marked as duplicate by Alex Chamberlain, Nils, Gilles, Michael Mrozek Jul 9 '12 at 2:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

There is escape char in ssh, by default this is tilde ~. It is recognized only at the beggining of a line.

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

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

share|improve this answer
1  
I wasn't typing it at the start of a line... – Alex Chamberlain Jul 5 '12 at 11:52
good one @paul .. thanks – Nikhil Mulley Jul 5 '12 at 13:25
4  
Incidentally, it's not just any start of a line - you have to have pressed enter right before ~. – Random832 Jul 5 '12 at 14:23

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

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.