ssh - 连接到/从 Ubuntu 18.04 时禁用 SSH 超时
问题描述
我在 Windows 上使用 putty 将 ssh 连接到我的 Digitaloccean 液滴,但 ssh 会话将在短暂不活动后过期。我需要什么配置来延长会话超时?
解决方案
您需要在 2 个地方设置配置:TESTED WORKING
客户端配置:
- 打开文件 /etc/ssh/ssh_config 并将指令 ServerAliveInterval 设置为类似 100 的值,例如:
# other configs
ServerAliveInterval 100
这会导致您的 SSH 客户端每 100 秒发送一次保持活动消息,以便服务器不会断开您的连接。
服务器配置
- 打开文件 /etc/ssh/sshd_config 并在文件末尾添加这些配置,以确保它们不会被后面的行覆盖:
# other configs
ClientAliveInterval 600
TCPKeepAlive yes
ClientAliveCountMax 10
这些是保守的设置,将使您的 SSH 服务器仅在 (600 * 10 = 6000) 秒的用户不活动后断开连接。如果您需要更多,请自定义这些。
重新启动 ssh 服务器以使更改生效:
$ sudo /etc/init.d/ssh restart
资料来源:http: //queirozf.com/entries/disabling-ssh-timeout-when-connecting-to-from-ubuntu
推荐阅读
- c++ - 反斜杠和引号不计入字符串长度?
- kotlin - Kotlin flatmap 解压数据类列表
- python - 是否有错误的解决方案:condarc invalid yaml 和 ConfigurationLoadError: Unable to load configuration file?
- angular - 动态地将文本墙上的每个单词转换为 Angular 7 中调用角度函数的(点击) - 使用什么?
- spring - 对于 Kotlin 未经检查的异常,Spring 不会回滚事务
- r - 在R图中用具有相同长度但半高的矩形替换正方形
- angular - 将参数传递给 Angular 组件中的 getter 的替代方法
- c# - Request.Form[] 始终为空
- c# - 计算listBox中的日期与当前计算机时钟的时间差
- javascript - 嵌套对象的键在格式化和渲染后丢失