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

Linux服務器配置---ssh配置

分鐘 lpad adding linux服務 table con 超時時間 interval color

Ssh配置

通過配置文件,我們可以有效的管理ssh

1、空閑時間關閉連接

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

[root@localhost wj]# gedit /etc/ssh/sshd_conf

ClientAliveInterval 10 //超時時間,10s

ClientAliveCountMax 0 //超時次數,0

[root@localhost wj]# service sshd restart //

重啟服務

停止sshd [確定]

正在啟動sshd [確定]

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

[root@localhost wj]# ssh [email protected]

[email protected]‘s password:

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

already login

[david@localhost ~]$ Connection to 192.168.0.119 closed by remote host.

Connection to 192.168.0.119 closed.

[root@localhost wj]#

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

1)修改配置文件“/etc/ssh/sshd_config”,設置參數“LoginGraceTime”

[root@localhost wj]# gedit /etc/ssh/sshd_config

LoginGraceTime 10s //這裏默認是2m,代表2分鐘。設置為10s,取消註釋

[root@localhost wj]# service sshd restart //重啟服務

停止sshd [確定]

正在啟動sshd [確定]

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

[root@localhost wj]# ssh [email protected]

[email protected]‘s password:

Connection closed by UNKNOWN

做了一個Linux學習的平臺,目前出來一個個形,各位可以參考使用
鏈接:https ://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ密碼:n7bk
技術分享圖片

Linux服務器配置---ssh配置