在CentOS系统中,限制Telnet访问权限可以通过以下几种方法实现:
安装firewalld(如果尚未安装):
sudo yum install firewalld
启动并启用firewalld服务:
sudo systemctl start firewalld
sudo systemctl enable firewalld
允许SSH访问(确保SSH端口22是开放的):
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
拒绝Telnet访问:
sudo firewall-cmd --permanent --remove-service=telnet
sudo firewall-cmd --reload
验证配置:
sudo firewall-cmd --list-all
编辑SSH配置文件:
sudo vi /etc/ssh/sshd_config
确保以下配置项存在并正确设置:
Port 22
PermitRootLogin no
PasswordAuthentication yes
AllowUsers your_username
将your_username
替换为你希望允许登录的用户名。
重启SSH服务:
sudo systemctl restart sshd
检查SELinux状态:
sestatus
如果SELinux处于 enforcing 模式,可以临时将其设置为 permissive 模式进行测试:
sudo setenforce 0
编辑SELinux策略文件(如果需要):
sudo vi /etc/selinux/config
将SELINUX=enforcing
改为SELINUX=permissive
,然后重启系统。
验证配置:
getenforce
添加规则拒绝Telnet访问:
sudo iptables -A INPUT -p tcp --dport 23 -j DROP
保存iptables规则:
sudo service iptables save
重启iptables服务:
sudo systemctl restart iptables
通过以上方法,你可以有效地限制CentOS系统上的Telnet访问权限,提高系统的安全性。