Putty连阿里云CentOS7.3服务器总是掉线的解决方法

来源:互联网 发布:c语言工资计算系统 编辑:程序博客网 时间:2024/05/16 06:36
申请了阿里云的服务器,CentOS7.3的系统,经常出现一会就掉线,需要从新登录才行。找到如下解决方案,实验下是否可行。


1. echo ¥TMOUT
如果显示空白,表示没有设置,等于使用默认值0, 一般情况下应该是不超时。如果大于0,可以在如/etc/profile之类文件中设置它为0。
Definition: TMOUT: If set to a value greater than zero, thevalue is interpreted as the number of seconds to wait for inputafter issuing the primary prompt. Bash terminates after waiting forthat number of seconds if input does not arrive.


2. 修改/etc/ssh/sshd_config文件
a. 将 ClientAliveInterval 0和ClientAliveCountMax 3的注释符号去掉;
b. 将ClientAliveInterval对应的0改成60,ClientAliveInterval指定了服务器端向客户端请求消息的时间间隔,默认是0,不发送。而ClientAliveInterval60表示每分钟发送一次,然后客户端响应,这样就保持长连接了。
c.ClientAliveCountMax,使用默认值3即可。ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值,就自动断开。正常情况下,客户端不会不响应。
d. 执行service sshd restart 或 /etc/init.d/sshdrestart,使改过的配置生效。
原创粉丝点击