使SSH会话保持活动状态 [英] Keep SSH session alive

查看:108
本文介绍了使SSH会话保持活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ssh -p8520 username@remote_host登录远程服务器.

I use ssh -p8520 username@remote_host to login remote server.

问题:

当我在工作场所时,它始终保持连接并且可以正常工作.不幸的是,在我从家里连接到远程服务器后,终端会在10到15分钟内死机.

It is always connected and works properly when I am in the work place. Unfortunately, terminal freezes in 10 - 15 minutes after I connected with the remote server from home.

控制台上没有错误/超时报告,但光标无法再移动.

There's no error/timeout report on the console but the cursor cannot move any more.

输入 w 来检查登录用户时,那里有一些僵尸登录用户,我必须手动将其杀死.

When enter w to check the login users, some zombies login users are there, and I have to kill them manually.

这很烦人.谁能帮我?

This is quite annoying. Can anyone help me?

推荐答案

在服务器端运行的ssh守护程序(sshd)如果客户端保持静默状态(即不发送信息),则从服务器端关闭连接. ).为了防止连接丢失,请指示ssh客户端不时向服务器发送生命周期信号.

The ssh daemon (sshd), which runs server-side, closes the connection from the server-side if the client goes silent (i.e., does not send information). To prevent connection loss, instruct the ssh client to send a sign-of-life signal to the server once in a while.

此配置位于文件$HOME/.ssh/config中,如果文件不存在则创建该文件(配置文件不能被世界读取,因此在创建文件后运行chmod 600 ~/.ssh/config).每次发送信号四分钟(240秒)到远程主机,将以下内容放入该配置文件:

The configuration for this is in the file $HOME/.ssh/config, create the file if it does not exist (the config file must not be world-readable, so run chmod 600 ~/.ssh/config after creating the file). To send the signal every e.g. four minutes (240 seconds) to the remote host, put the following in that configuration file:

Host remotehost
    HostName remotehost.com
    ServerAliveInterval 240

要启用向所有主机发送保持活动信号的功能,请将以下内容放入配置文件中:

To enable sending a keep-alive signal for all hosts, place the following contents in the configuration file:

Host *
    ServerAliveInterval 240

这篇关于使SSH会话保持活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆