在 Ubuntu 上使用 telnet 报错,常见原因和对应解决方法如下:
报错示例:
Command 'telnet' not found
或
telnet: command not found
原因:
Ubuntu 默认不安装 telnet 客户端。
解决:
sudo apt update
sudo apt install telnetd # 或 telnet(部分版本)
# 实际常用:
sudo apt install telnet
注意:有些版本包名是
telnet,有些是inetutils-telnet
报错示例:
telnet: Unable to connect to remote host: Connection refused
原因:
排查:
# 在目标机查看端口
ss -lntp | grep 23
解决:
ssh报错示例:
telnet: Unable to connect to remote host: Connection timed out
原因:
排查:
ping 目标IP
traceroute 目标IP
报错示例:
telnet: could not resolve hostname
解决:
telnet 192.168.1.10 23
或用:
nslookup 域名
现代 Ubuntu 默认不推荐 telnet,因为:
✅ 推荐替代:
ssh user@host
或测试端口:
nc -vz host port
可以把 完整报错内容 发出来,我可以精准判断(例如:
bash: telnet: command not foundConnection refusedNo route to host
)