Table: LinuxNotes
User: dreamable
Created at: 2021-05-12 11:21:28 UTC
Updated at: 2021-05-12 11:21:39 UTC
Reference:(Table ID 28, Record ID 3)

标题 :
How do I resolve a ssh connection closed by remote host due to inactivity?
笔记 :


  • Add to .ssh/config
TCPKeepAlive yes
ServerAliveInterval 30
  • In command line
ssh -o TCPKeepAlive=yes
ssh -o ServerAliveInterval=30

TCPKeepAlive: This uses the KEEPALIVE option of the TCP/IP protocol to keep a connection alive after a specified interval of inactivity. On most systems, this means 2 hours. So, with the TCPKeepAlive option passed to SSH, the SSH client will send an encrypted packet to the SSH server, keeping your TCP connection up and running.

ServerAliveInterval: This sets a timeout interval in seconds, which is specified by you, from which if no packets are sent from the SSH client to the SSH server, SSH will send an encrypted request to the server for a TCP response. To make that request every 30 seconds: