作为IT工程师,我将为您提供在CentOS系统上禁用不安全网络协议和服务的详细步骤,以提高系统安全性。
编辑OpenSSL配置文件:
sudo vi /etc/ssl/openssl.cnf
找到Protocol
部分,确保包含以下内容:
MinProtocol = TLSv1.2
Options = -SSLv2, -SSLv3, -TLSv1, -TLSv1.1
编辑SSH配置文件:
sudo vi /etc/ssh/sshd_config
修改或添加以下参数:
Protocol 2
HostKeyAlgorithms ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com
sudo yum remove telnet-server vsftpd -y
sudo systemctl list-unit-files --type=service | grep enabled
禁用常见不必要的服务:
sudo systemctl disable rpcbind
sudo systemctl disable nfs
sudo systemctl disable rsh.socket
sudo systemctl disable rexec.socket
sudo systemctl disable rlogin.socket
sudo systemctl disable ypbind
编辑sysctl配置:
sudo vi /etc/sysctl.conf
添加以下内容:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
应用更改:
sudo sysctl -p
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo firewall-cmd --permanent --remove-service=dhcpv6-client
sudo firewall-cmd --permanent --remove-service=ssh
sudo firewall-cmd --permanent --add-service=ssh --zone=work
sudo firewall-cmd --permanent --add-port=80/tcp --zone=work
sudo firewall-cmd --reload
编辑sysctl配置:
sudo vi /etc/sysctl.conf
添加:
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
在/etc/sysctl.conf
中添加:
net.ipv4.tcp_syncookies = 1
应用所有sysctl更改:
sudo sysctl -p
sudo netstat -tulnp
sudo ss -tulnp
openssl s_client -connect localhost:443 -ssl3 # 应该失败
openssl s_client -connect localhost:443 -tls1_2 # 应该成功
sudo yum install nmap -y
nmap -sV --script ssl-enum-ciphers -p 443 localhost
sudo yum update -y
sudo systemctl list-unit-files --type=service | grep enabled
sudo netstat -tulnp
sudo firewall-cmd --list-all
通过以上步骤,您可以显著提高CentOS系统的网络安全性,禁用不安全的协议和服务,减少潜在的攻击面。