ssh 断开解决办法


SSH连接总是隔一段时间没有输入时就断开,解决办法如下:

服务端配置
sudo vi /etc/ssh/sshd_config
ClientAliveInterval 60     #服务端主动向客户端请求响应的间隔
ClientAliveCountMax 10    #服务器发出请求后客户端没有响应的次数达到一定值就自动断开
sudo restart ssh

客户端配置 
sudo vi /etc/ssh/ssh_config  #或~/.ssh/config

TCPKeepAlive=yes

ServerAliveInterval 60   #客户端主动向服务端请求响应的间隔

ssh -i <key-file> -o StrictHostKeyChecking=no -o TCPKeepAlive=yes -o ServerAliveInterval=30 ubuntu@<ip>

上面方式任选一种,我选客户端配置方式。



猜你喜欢

转载自www.cnblogs.com/williamjie/p/10276789.html