9

Connecting from Ubuntu Desktop x64 14.04's ssh client to an Ubuntu Server 14.04 x64 SSH server on Microsoft Azure.

Unfortunately when it is connected and left idle for a time; the connection freezes but doesn't disconnect.

I have tried setting these variables in my server's /etc/ssh/sshd_config:

ClientAliveInterval 30
TCPKeepAlive yes
ClientAliveCountMax 99999
masegaloeh
  • 18,236
  • 10
  • 57
  • 106
A T
  • 397
  • 1
  • 4
  • 15
  • man ssh_config can help on the client side – c4f4t0r Apr 19 '14 at 18:26
  • Does the connection disconnect if you press a key in the SSH window after freezing? It might take a minute or two before it disconnects. If this is the case, then network connectivity problems between the two cause this problem. – Tero Kilkanen Apr 20 '14 at 00:48
  • I see the same behavior in connecting via SSH to Rackspace Cloud Servers after upgrading my workstation to 14.04. This implies it's a client bug and not something wrong with sshd or Azure. – jalefkowit May 30 '14 at 19:22
  • I had the same problem, resolved it by using Mosh. – Janus Troelsen Jun 03 '14 at 14:33
  • As a workaround i run this script when idling: `while true; do echo -n $'\r'$i; echo -n $(date +"%H:%M:%S"); sleep 5; done` – LatinSuD Jun 04 '14 at 12:26
  • You can try this one too: `while true; do for i in - '\' '|' '/'; do echo -n $'\r'$i; sleep 1; done; done` – LatinSuD Jun 04 '14 at 12:29
  • When the connection freezes take a look on the state of the TCP connection in each end of the connection. You could use `netstat -ntp` to look at the state of the connection. Before the connection freeze, you could use `echo $SSH_CONNECTION` to find the relevant connection. – kasperd Jun 04 '14 at 18:46

1 Answers1

6

on the connecting client, in /etc/ssh/ssh_config, try:

ServerAliveInterval 60

not sure why the ClientAliveInterval is not working for you on the server.... maybe you need to restart sshd, if you did not do so after adding the ClientAliveInterval directive?

if you do not have root on the client, you can stick the ServerAliveInterval in

~/.ssh/config

nandoP
  • 2,021
  • 14
  • 15
  • 2
    Perhaps `KeepAlive yes` is missing. At any rate I think keepalives will solve this user's problem nicely. The only risk with keepalives is that connection problems can trigger the connection to die whereas without keepalives some connectivity problems between you and server may go unnoticed gracefully. – regulatre Jun 06 '14 at 14:30