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
通过配置文件,我们可以有效的管理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