Ubuntu – SSH Connections freezing with “Write failed: Broken pipe”

centossshtimeoutUbuntu

I am connecting to a CentOS 5.5 box via SSH from a Ubuntu 11.04 machine.

The connection appears to work as expected when it is in active use (i.e. no lag or loss), but if it is left inactive for a while it will freeze up and become unresponsive. Eventually the error message "Write failed: Broken pipe" will be returned and I'll be back on my local machine's prompt.

What sort of things can I do to help debug this, find out what is happening, and get this resolved?
Being a developer, this is making my life a pain having to reconnect constantly.

Best Answer

It looks like the CentOS box's SSHD config is not set to do the client KeepAlive.

Drop these two lines in your CentOS sshd config (/etc/ssh/sshd_config), restart it, and enjoy!

KeepAlive yes
ClientAliveInterval 60

While you're at it, I'd recommend using gnu screen to keep your session alive on the CentOS side.