I have a SSH disconnection problem, disconnection occurs randomly. Sometimes, it works fine and other times I am frequently disconnected. After the disconnection I can again re-connect and continue to work.

Between the client to destination server ssh connectivity the flow is like this:

  Client (C1)   ->   Intermediate Server (I)   -> Destination Server (R1)
(Windows/Linux) -> (Linux + OpenVPN/IPTables)  ->         (Linux)    

Routing from Client C1 to destination server R1always happens through intermediate server I.

With Wireshark, I could see the RST packets I'm getting whenever I have a disconnection issue. Wireshark logs on C1 shows R1 is sending RST tcp pakets whenever I get a disconnection problem.

What could be causing this issue?

migrated from stackoverflow.com Jul 15 '11 at 3:40

This question came from our site for professional and enthusiast programmers.

  • Can you capture on (I) and on (R1)? Which of those is really sending the RST packets? – joechip Jul 15 '11 at 4:07

Without delving into your particular problem, I've found these configuration lines have solved similar issues for me:

ClientAliveInterval 150
ClientAliveCountMax 10

It solves disconnects due to laggy or flapping links. I'm not saying these are perfect values, but they have worked for me so far.

  • I found that keepalives actually exacerbated disconnects on poor quality connections. The connection would drop because the keepalive failed. Without it, the period of congestion would go unnoticed as the link was not transmitting. In other situations where the firewall state table would eventually purge, keepalives helped the SSH connection remain in the state table. – Jodie C Jul 22 '11 at 18:30

Turn on keepalive. Add the following line to your .ssh/config:

ServerAliveInterval 60

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy