在 CentOS 上开启并使用 telnet(仅建议测试或内网使用,生产环境不推荐,建议用 SSH):
yum install -y telnet-server xinetd
dnf install -y telnet-server xinetd
CentOS 的 telnet 依赖 xinetd:
systemctl enable xinetd
systemctl start xinetd
确认服务状态:
systemctl status xinetd
firewall-cmd --permanent --add-service=telnet
firewall-cmd --reload
或手动开放端口:
firewall-cmd --permanent --add-port=23/tcp
firewall-cmd --reload
默认 禁止 root 通过 telnet 登录(安全限制)。
如需允许(仅测试环境):
vi /etc/securetty
添加:
pts/0
pts/1
pts/2
在另一台机器:
telnet 服务器IP
或本地测试:
telnet localhost
securettyssh user@ip
如你使用的是 CentOS 版本不明确 或 最小化安装,可以告诉我具体版本,我给你更精确的命令。