在 Debian 上使用 telnet 报错,常见原因和对应解决办法如下:
Debian 默认 不安装 telnet 客户端。
现象
bash: telnet: command not found
解决
sudo apt update
sudo apt install telnet
现象
Trying 192.168.1.10...
telnet: Unable to connect to remote host: Connection refused
原因
排查
ss -lntp | grep :23
或
nmap -p 23 目标IP
⚠️ 现代系统已基本弃用 telnet(明文传输),建议用
ssh
现象
Trying 192.168.1.10...
telnet: Unable to connect to remote host: Connection timed out
原因
排查
ping 目标IP
iptables -L
例如:
telnet 192.168.1.10 22
会连上但马上乱码或断开,这是正常的(那是 SSH)。
Debian 默认 没有 telnet 服务端
安装:
sudo apt install telnetd
sudo systemctl enable --now inetd
telnet: could not resolve host
检查:
cat /etc/hosts
getent hosts 主机名
telnet 不安全,生产环境不建议使用:
ssh user@hostnc / curl / socat 测试端口如果你能贴出 具体报错信息(完整一行),我可以直接帮你定位是哪一类问题。