在Debian系统中禁止Telnet访问可以通过以下步骤实现:
安装iptables(如果尚未安装):
sudo apt update
sudo apt install iptables
阻止Telnet端口(默认是23):
sudo iptables -A INPUT -p tcp --dport 23 -j DROP
保存iptables规则:
Debian系统通常使用iptables-persistent来保存规则。如果没有安装,可以安装并启用它:
sudo apt install iptables-persistent
在安装过程中,选择“是”以保存当前规则。
重启iptables服务(可选,但推荐):
sudo systemctl restart netfilter-persistent
安装UFW(如果尚未安装):
sudo apt update
sudo apt install ufw
启用UFW:
sudo ufw enable
阻止Telnet端口(默认是23):
sudo ufw deny 23/tcp
重新加载UFW规则(如果需要):
sudo ufw reload
如果你希望用户使用SSH而不是Telnet进行远程登录,可以修改SSH配置文件:
编辑SSH配置文件:
sudo nano /etc/ssh/sshd_config
确保以下配置项存在并正确设置:
Port 22
PermitRootLogin no
PasswordAuthentication yes
重启SSH服务:
sudo systemctl restart sshd
通过以上方法,你可以有效地禁止Debian系统上的Telnet访问,从而提高系统的安全性。