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                                            [确定]

扫描二维码关注公众号,回复: 4652962 查看本文章

        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

猜你喜欢

转载自www.cnblogs.com/wj78080458/p/10061152.html