Linux服务器---ssh配置

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

 



猜你喜欢

转载自blog.51cto.com/9888479/2335323