Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

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

share|improve this answer
add comment

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!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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