bash
# 追加ssh配置,解释见后文
cat <<EOF | sudo tee -a ~/.ssh/config
Host *
ServerAliveInterval 30
ServerAliveCountMax 3
TCPKeepAlive yes
EOF
- ServerAliveInterval 30:每 30 秒发送一次心跳包
- ServerAliveCountMax 3:连续 3 次无响应则断开重连
- TCPKeepAlive yes:启用 TCP 层 keepalive