centos7.9安全加固

昵称昵称昵称 / 2023-08-17 / 原文

centos7.9安全加固

 

1、限制用户登陆

vim /etc/hosts.deny,若禁止192.168.0.158对服务器进行ssh的登陆,添加如下内容
sshd : 192.168.0.158

添加完毕后就生效了,直接用192.168.0.158访问主机,就无法连接了,显示
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(192.168.0.x:22) at 09:46:24.

 

2、限制密码尝试失败次数
修改vim /etc/ssh/sshd_config
MaxAuthTries 2

SSH连接服务器密码尝试次数为2次,输错两次后自动断开连接

 设置完毕后,必须重启SSH服务systemctl restart sshd

3、修改SSH默认连接端口
修改vim /etc/ssh/sshd_config
Port 222

  设置完毕后,必须重启SSH服务systemctl restart sshd