MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
October
Sun Mon Tue Wed Thu Fri Sat
   
8
   
2013
Months
Oct


Tue, Oct 08, 2013 10:39 pm

Keeping an SSH connection alive with ServerAliveInterval

While working on a Ubuntu Linux laptop, I found my SSH sessions to a Linux server were being dropped after a few minutes when I switched to other tasks on the laptop. Using the ServerAliveInterval parameter when establishing the SSH connection allowed me to alleviate the problem of idle connections being dropped. E.g., I could use:
$ ssh -o ServerAliveInterval=5 -o ServerAliveCountMax=1 jdoe@a.example.com

Setting the ServerAliveInterval to 5 will send a "heartbeat" signal to the server every 5 seconds to keep the connection alive. Setting ServerAliveCountMax to 1 means that when the time comes to send another keepalive signal, if a response to the last one wasn't received, then the connection will be terminated.

The TCPKeepAlive setting could also be used, but, if there is an intervening firewall it might be configured to drop the empty TCP ACK packets that would be sent. The ServerAliveInterval setting sends data through the SSH connection, so from the perspective of the firewall the packets are the same as any other encrypted packet.

References:

  1. How does tcp-keepalive work in ssh?
    Date: March 12, 2012
    Unix & Linux Stack Exchange
  2. Keeping Your SSH Sessions Alive Through Pesky NAT Firewalls
    Date: June 3, 2005
    Steve Kehlet's Pages

[/network/ssh] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo