10

This is a very simple problem. I use gnome-terminal to SSH to other machines every day. I do this on a laptop which I carry around the office, so I am constantly switching between wired and wireless networks. When this happens my SSH sessions drops off and the terminal freezes.

Why does this happen (the freezing, not the session dropping) and is their a way to prevent it? I know I can get around this by logging off from the remote server before I know I want to disconnect my laptop from Ethernet.

It's annoying because I have to manually close the terminal session after it has frozen which pops up a dialogue box and I also lose the title of the session - all very time consuming. It would be much better if the ssh session just got killed and it returned me back to the local bash prompt.

  • Try pressing Ctrl + D – becko Aug 18 '14 at 14:07
16

The session will eventually time out and disconnect; this will happen faster if you configure ServerAliveInterval and ServerAliveCountMax in ~/.ssh/config. To force an immediate disconnect, Return~..

4

Without getting into the why of it, here's how you fix it:

~.

that's tilde-dot. Press those two keys, one after another, and that will disconnect from the hung ssh session and give you back your terminal. Yay!

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.