六、Linux_SSH服务器状态

一、保持Xshell连接Linux服务器状态

1、登录服务器后

cd /etc/ssh/
vim sshd_config

找到 ClientAliveInterval 0和ClientAliveCountMax 3
将注释符号("#")去掉,
将ClientAliveInterval对应的0改成3600,保存。
ClientAliveInterval 指定了服务器端向客户端请求消息 的时间间隔, 默认是0, 不发送.
ClientAliveInterval 3600每1个小时发送一次, 然后客户端响应, 保持长连接.
ClientAliveCountMax, 使用默认值3,
ClientAliveCountMax 服务器发出请求后客户端没有响应的次数达到 3, 就自动断开.

2、重启ssh服务

service sshd restart

# 如果Redirecting to /bin/systemctl restart sshd.service,则使用下面的方式启动:
systemctl restart sshd.service

3、查看 sshd 服务是否启动:

#方式一:
systemctl status sshd.service

#方式二、systemctl命令如果没有,试试这个命令
ps -ef | grep ssh

#查看ssh服务有没有运行,如果有,可以看到类似以下内容:

root 2659 1 0 18:31 ? 00:00:00 /usr/sbin/sshd
root 2702 2618 0 18:38 pts/0 00:00:00 grep ssh
# 这证明ssh已经在运行了,进程名为sshd

4. 如果没有启动,则需要启动该服务:

service sshd start
# 或者下面的命令
systemctl start sshd.service

 

二、sshd服务相关的操作

1.重启 sshd 服务:

systemctl restart sshd.service

2.设置服务开自启:

systemctl enable sshd.service

 

参考文章:
保持Xshell连接Linux服务器状态:https://blog.csdn.net/fatong3/article/details/79320767?utm_source=blogxgwz5
使用xshell-ssh连接服务器被经常意外中断:https://blog.csdn.net/iamoldpan/article/details/77595624
linux安装ssh和开启 ssh服务:https://blog.csdn.net/eddy23513/article/details/81366507

posted @ 2019-11-08 09:18  心静无忧  阅读(1683)  评论(0编辑  收藏  举报