一、保持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