主机ssh长连接远程服务器
【主机ssh长连接远程服务器】我购买一台远程服务器(Ubuntu 19.04),每次本地主机访问ssh远程服务器时,连接时间特别短!!!
解决方法
root@vultr:~# vim /etc/ssh/sshd_config//服务器端编辑sshd_config文件
#sshd_config
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
ClientAliveInterval 30//指定server向host请求消息的时间间隔,默认是0,不发送。当clientAliveInterval=60表示每半分钟发送一次,然后客户端响应。
ClientAliveCountMax 999999999//默认数值是3,clientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值,就自动断开。我亲自实测,数值`越大`,连接时长越长。正常情况下,client不会不响应的。
总结
ClientAliveInterval 60表示每分钟发送一次,然后客户端响应,这样就保持长连接了。ClientAliveCountMax,使用默认值3即可,ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值,就自动断开,设成10000或更大,保证不断开。
推荐阅读
- 增长黑客的海盗法则
- 学无止境,人生还很长
- 人生感悟记#环境仪器宋庆国成长记#072
- “成长”读书社群招募
- 长沙小吃糖油粑粑
- 星耀小学二年三班姜婉莹成长曰记第8天
- 七律丨游长安晚归
- [青春]翔(五)
- SSH|SSH 免密
- 唐嫣可真会穿,西装搭牛仔裤都能穿出高级感,一双大长腿太抢镜