以下是Debian下Telnet服务端配置要点及安全建议:
安装服务
sudo apt update
sudo apt install inetd xinetd telnetd # 安装依赖包
启用服务
编辑配置文件 /etc/inetd.conf 或 /etc/xinetd.d/telnet,取消注释或添加以下内容:
service telnet
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/in.telnetd
}
注:部分系统需通过xinetd管理,确保/etc/xinetd.d/telnet存在并启用。
重启服务
sudo systemctl restart inetd # 或 xinetd
限制访问IP
/etc/hosts.allow和/etc/hosts.deny,仅允许特定IP访问:# /etc/hosts.allow
in.telnetd: 192.168.1.0/24
# /etc/hosts.deny
in.telnetd: ALL
ufw限制端口访问:sudo ufw allow from 192.168.1.0/24 to any port 23
sudo ufw deny telnet # 拒绝其他来源
禁用明文传输(可选)
Telnet默认明文传输,可通过配置/etc/xinetd.d/telnet添加-h参数启用加密(需配合SSH隧道使用,但效果有限):
server_args = -h
由于Telnet存在严重安全风险,建议直接使用SSH替代:
安装SSH服务
sudo apt install openssh-server
sudo systemctl start ssh
sudo systemctl enable ssh
配置SSH安全策略
编辑/etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AllowUsers your_username
/var/log/auth.log)监控异常登录行为。以上配置参考自,实际操作前建议备份配置文件。