方法1:
#vim /etc/ssh/sshd_config(添加或修改以下配置)
ClientAliveInterval 60(每隔60秒給SSH客戶端發送一次信號)
ClientAliveCountMax 1440(超時達到多少次數后斷開SSH客戶端連接)
上面配置表中的#注釋需要去掉
#systemctl restart sshd.service(重啟SSH服務)
SSH重啟成功顯示:Redirecting to /bin/systemctl restart sshd.service
方法2:
#echo export TMOUT=1000000 >> /root/.bash_profile (設定環境變數為1000000,用戶沒有操作時,超過該秒斷開SSH會話)
#cat /root/.bash_profile (列印查看是否寫入)
#source .bash_profile
#cp /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
#echo ClientAliveInterval=60 >> /etc/ssh/sshd_config
#service sshd restart (重啟SSH服務)
#cat /etc/ssh/sshd_config
#exit
方法3:
export timeout = -1
每次上線需要設定一次,這個方法不寫配置表,
相關:
無法重啟ssd 服務時,使用以下指令查詢錯誤,
/usr/sbin/sshd -T
比如查詢到2個錯誤:

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/154793.html
標籤:Linux
下一篇:大學網路工程與管理怎么辦
