I'm using cygwin. and use it with ssh to login into a ubuntu server. sometimes, I want to switch back to my cygwin and then quickly switch to ubuntu shell. How to do this?


You can background the ssh client just like any other shell job by sending it a signal and returning to the parent shell. Since the ssh client traps most key strokes, it would grab the normal shell job control keystrokes, but you can get its attention and get through to the shell using an escape sequence. For most ssh-clients this involves sending a ~ that has been directly preceded by a newline. The following sequence should do the job:

Enter ~ Ctrl+Z

After it is suspended you can continue using the local shell. When you want to go back to the suspended job, just run the fg command.

For further reading, look up Bash Job Control.

| improve this answer | |
  • 3
    Nice; beat me to it. For more further reading, run man ssh and search for "Escape Characters", or type ~? in an ssh session. – Jander Oct 14 '11 at 14:22

@Caleb's answer is good, but you could also consider installing a terminal multiplexer like screen or tmux. Apparently (according to what I can find on the web) tmux has had some problems with running on Cygwin in the past, but I don't know about the current status of it.

| improve this answer | |
  • 2
    Both tmux and screen can certainly be used to solve the problem the OP is facing, but getting started with a multiplexer is quite pile of stuff to get your head around the first time. Perhaps you could expand this answer to an exact set of commands for tmux that would get a newcomer through the process of opening a terminal, ssh'ing, detatching back to the main shell, then attaching again... – Caleb Oct 19 '11 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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