1. 程式人生 > >Linux伺服器配置---ssh配置

Linux伺服器配置---ssh配置

Ssh配置    

        通過配置檔案,我們可以有效的管理ssh

1、空閒時間關閉連線

        1)修改配置檔案“/etc/ssh/sshd_config”,設定clientAliveInterval和clientAliveCountMax,注意取消前面的註釋

[[email protected] wj]# gedit /etc/ssh/sshd_conf

ClientAliveInterval 10       //

超時時間,10s

ClientAliveCountMax 0        //超時次數,0

 

[[email protected] wj]# service sshd restart           //重啟服務

停止sshd                                               [

確定]

正在啟動sshd                                            [確定]

        2)測試超時,登入之後不要進行任何操作,10s之後連線就會關閉

[[email protected] wj]# ssh [email protected]

[email protected]'s password: 

Last login: Thu Aug 16 08:22:25 2018 from 192.168.0.119

already login

[[email protected] ~]$ Connection to 192.168.0.119 closed by remote host.

Connection to 192.168.0.119 closed.

[[email protected] wj]#

 

2、輸入密碼超時,關閉連線

        1)修改配置檔案“/etc/ssh/sshd_config”,設定引數“LoginGraceTime” 

[[email protected] wj]# gedit /etc/ssh/sshd_config 

LoginGraceTime 10s    //這裡預設是2m,代表2分鐘。設定為10s,取消註釋

 

[[email protected] wj]# service sshd restart           //重啟服務

停止sshd                                               [確定]

正在啟動sshd                                            [確定]

        2)測試,登入的時候不輸入密碼,連線會自動斷開

[[email protected] wj]# ssh [email protected]

[email protected]'s password: 

Connection closed by UNKNOWN

 

 

    做了一個Linux學習的平臺,目前出來一個個形,各位可以參考使用
連結:https   ://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ密碼:n7bk