When I connect via ssh terminal to certain servers, it timeouts and "freezes" the terminal (doesn't accept, doesn't disconnect, can't Ctrl-C to kill the ssh process or anything).

This is in Ubuntu's Gnome-terminal, though it seems to be pausing the terminal input/output, and doesn't affect the operation of the Gnome-terminal software itself. so less a bug with gnome-terminal than an annoying inconsistency with ssh.

So is there a way to prevent regain the terminal from ssh connections that have timed out?

link|improve this question

75% accept rate
feedback

2 Answers

up vote 14 down vote accepted

sshd (the server) closes the connection if it doesn't hear anything from the client for a while. You can tell your client to send a sign-of-life signal to the client once in a while.

The configuration for this in the file ~/.ssh/config. To send the signal every four minutes to remotehost, put the following in your ~/.ssh/config.

Host remotehost
  HostName remotehost.com
  ServerAliveInterval 240

This is what I have in my ~/.ssh/config.

To enable it for all hosts use:

Host *
  ServerAliveInterval 240

Also make sure to run chmod 600 ~/.ssh/config, because the config file must not be world-readable.

link|improve this answer
Thanks, that sounds pretty much like what I'm looking for. – Tchalvak Jan 21 '10 at 17:40
Thanks sblair for helping me with the wording, it's much appreciated. I changed "should not" back to "must not" because ssh checks the permissions of the file and if it is world or group readable it fails. – Ludwig Weinzierl Oct 1 '11 at 20:26
feedback

Press Enter, ~, . one after the other. The section "ESCAPE CHARACTERS" in the ssh man page explains the underlying details.

link|improve this answer
I'll try that out if the config solution doesn't work and it happens again, thanks. – Tchalvak Jan 21 '10 at 17:41
feedback

Your Answer

 
or
required, but never shown

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