ssh远程连接会在无操作时自动断开连接。为了保持程序运行和连接,需要设置保持连接。

1.MobaXterm

如果使用了MobaXterm客户端,那么需要在设置里点选setting>SSH>sessions setting>勾选ssh Keepalive

  • keepalive
    【MobaXterm】设置保持SSH连接
    选择下图的选项即可:
    【MobaXterm】设置保持SSH连接

2.SSH

如果使用的是ssh则需要设定超时连接的时间/etc/ssh/sshd_config

  • 服务器端要设置客户的超时重连:
ClientAliveCountMax 3    #默认重连3次
ClientAliveInterval 30   #30s重连一次
  • 客户端要设置服务器端的超时重连(user 设置文件在~/.ssh/下):
ServerAliveCountMax 3
ServerAliveInterval 30

重启服务service sshdservice sshd restart

另一种很直接的方法,直接使用ssh命令参数:
ssh -o ServerAliveInterval 30将超时重连传进去。
【MobaXterm】设置保持SSH连接
icon from easyicon


ref:
ssh:https://www.ssh.com/ssh/sshd_config/
openssh:http://www.jinbuguo.com/openssh/sshd_config.html
mobaxterm:https://mobaxterm.mobatek.net/documentation.html#6_8_4
https://blog.csdn.net/yelllowcong/article/details/76850708
https://blog.csdn.net/abld99/article/details/69388858

相关文章:

  • 2022-01-02
  • 2021-09-15
  • 2022-12-23
  • 2021-05-16
  • 2021-10-07
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
相关资源
相似解决方案