SecureCRT 远程登录连接Linux/Unix服务器时,一段时间不用会自动断开连接,需要重新连接,比较麻烦。

1. 服务器端配置

1.1 修改 /etc/profile 或 ~/.bash_profile

vim /etc/profile 或 vim ~/.bash_profile

TMOUT=1800 // 添加到 /etc/profile 文件最后一行,单位为秒,1800秒即为30分钟

source /etc/profile // 使修改生效

注意: TMOUT设置的服务器超时时间,一定要大于SecureCRT设置反空闲时间,不然还没反超时就自动断开了

1.2 修改 /etc/ssh/sshd_config

vim /etc/ssh/sshd_config

ClientAliveInterval 180 // 去掉#,设置为180秒,每隔3分钟服务器端向客户端请求一次消息的时间间隔;默认0,表示不发送

ClientAliveCountMax 3 // 去掉#,表示服务器向客户端发送请求没有响应的次数就自动断开;正常情况下, 客户端不会不响应

service sshd restart 或 service sshd reload // 使修改生效

注意:设置以后,SecureCRT一定要退出远程连接,重新登陆一次

2. 客户端配置

2.1 设置 NO-OP

Options -> Session Options -> Terminal -> Anti-idle -> (勾选) Send protocol NO-OP -> 60(单位秒,1分钟发送一次请求)

2.2 全局设置

SecureCRT —> Preferences… —> Default Session —> Edit Default Settings —> Terminal -> Anti-idle -> (勾选) Send protocol NO-OP -> 60

3. 验证生效

SecureCRT没有操作时,每隔60秒,自动发送一个换行符(\n)给服务器端,并在SecureCRT客户端执行换行操作

这样客户端和服务器端有操作连接,保证了远程连接的保持,不会掉线。

putty -> Connection -> Seconds between keepalives ( 0 to turn off ), 默认为0, 改为300.


版权声明:本文为weixin_39541750原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_39541750/article/details/111834672