目錄
原因
用putty/SecureCRT連續3分鍾左右沒有輸入, 就自動斷開, 然后必須重新登陸,。
解決方法
一般修改兩個地方可將這煩人的問題解決
1、echo $TMOUT
如果顯示空白,表示沒有設置, 等於使用默認值0, 一般情況下應該是不超時. 如果大於0, 可以在如/etc/profile之類文件中設置它為0.
Definition: TMOUT: If set to a value greater than zero, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive
2、修改/etc/ssh/sshd_config文件,將 ClientAliveInterval 0和ClientAliveCountMax 3的注釋符號去掉,將ClientAliveInterval對應的0改成60,ClientAliveInterval指定了服務器端向客戶端請求消息 的時間間隔, 默認是0, 不發送.而ClientAliveInterval 60表示每分鍾發送一次, 然后客戶端響應, 這樣就保持長連接了.ClientAliveCountMax, 使用默認值3即可.ClientAliveCountMax表示服務器發出請求后客戶端沒有響應的次數達到一定值, 就自動斷開. 正常情況下, 客戶端不會不響應.
最后記得執行/etc/init.d/sshd restart service sshd restart哦,否則剛才的修改是不會生效的。