首页 > 应用开发 > > 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 david@192.168.0.119
david@192.168.0.119'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 david@192.168.0.119
david@192.168.0.119's password:
Connection closed by UNKNOWN
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2505/viewspace-3158689/ ,如需转载,请注明出处,否则将追究法律责任。