centos解決bash:telnet:command not found...&&telnet: connect to address 127.0.0.1: Connection refu...
2397 ワード
telnetがインストールされているかどうかを確認します。
[root@hostuser src]# rpm -q telnet-serverpackage telnet-server is not installed[root@hostuser src]# telnet 192.168.81.129bash: telnet: command not found...
rpm -qa |grep telnet
ない場合はインストール、スキップ
yum install telnet-server -y && yum install telnet.* -y
telnetサービスの開始
[root@hostuser src]# sudo service xinetd restartRedirecting to/bin/systemctl restart xinetd.service
telnetサービスの起動を確認する
[root@hostuser xinetd.d]# ps -ef | grep xinetdroot 33139 1 0 12:11 ? 00:00:00/usr/sbin/xinetd -stayalive -pidfile/var/run/xinetd.pidroot 35218 30125 0 12:27 pts/0 00:00:00 grep --color=auto xinetd
試してみる[root@hostuser src]# telnet localhostTrying::1...telnet: connect to address::1: Connection refusedTrying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refused[root@hostuser src]# netstat -tnl |grep 23
telnetのデフォルトポート23がファイアウォール23ポートを開通していないことを確認していません
オープン23ポート
firewall-cmd --zone=public --add-port=23/tcp --permanent
ファイアウォールfirewall-cmdの再起動--reloadチェックポートのオープン23状況
[root@hostuser xinetd.d]# firewall-cmd --zone=public --list-ports8989/tcp 8686/tcp 40127/tcp 23/tcp
もう一度[root@hostuser src]# telnet localhostTrying::1...telnet: connect to address::1: Connection refusedTrying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refused
cd/etc/xinetdを確認する.d
telnetファイルが存在しないか、touch telnetが存在しないかを確認します.
vi/etc/xinetd.d/telnet
追加
#default:yes
# description: The telnet server servestelnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server =/usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
直接変更がある場合
disable = no
その後xinetdを再起動します
[root@hostuser src]# sudo service xinetd restartRedirecting to/bin/systemctl restart xinetd.service
xinetdのPOSTを設定するには、次の手順に従います.
systemctl enable xinetd.service
telnet効果の確認
[root@hostuser xinetd.d]# telnet localhostTrying::1...Connected to localhost.Escape character is '^]'.
Kernel 3.10.0-957.10.1.el7.x86_64 on an x86_64hostuser login:
問題解決
転載先:https://www.cnblogs.com/SunshineKimi/p/10885392.html