centos7下安装telnet服务

先查看是否安装Telnet

[root@Hortonworks02 ~]# rpm -qa | grep telnet
telnet-server-0.17-64.el7.x86_64
telnet-0.17-64.el7.x86_64

若没有安装,则分别安装telnet 和 telnet-server

[root@Hortonworks02 ~]# yum install telnet-server
Loaded plugins: fastestmirror
Repository HDP-UTILS-1.1.0.21 is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
–> Running transaction check
—> Package telnet-server.x86_64 1:0.17-64.el7 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
Package Arch Version Repository Size
\==================================================================================================================================
Installing:
telnet-server x86_64 1:0.17-64.el7 base 41 k
Transaction Summary
\==================================================================================================================================
Install 1 Package
Total download size: 41 k

注意:telnet-server服务启动依赖xinetd服务。

查看是否安装xinetd

[root@Hortonworks02 ~]# rpm -qa | grep xinetd
[root@Hortonworks02 ~]#

安装xinetd

[root@Hortonworks02 ~]# yum install -y xinetd
Loaded plugins: fastestmirror
Repository HDP-UTILS-1.1.0.21 is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies

Transaction test succeeded
Running transaction
Installing : 2:xinetd-2.3.15-13.el7.x86_64 1/1
Verifying : 2:xinetd-2.3.15-13.el7.x86_64 1/1
Installed:
xinetd.x86_64 2:2.3.15-13.el7
Complete!

开启xinetd服务并设置为开机自启。

[root@Hortonworks02 ~]# systemctl enable xinetd.service
[root@Hortonworks02 ~]# systemctl status xinetd.service
● xinetd.service - Xinetd A Powerful Replacement For Inetd
Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)
Active: inactive (dead)
[root@Hortonworks02 ~]# systemctl start xinetd.service
[root@Hortonworks02 ~]# systemctl status xinetd.service
● xinetd.service - Xinetd A Powerful Replacement For Inetd
Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-01-18 09:59:00 CST; 2s ago
Process: 55642 ExecStart=/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid $EXTRAOPTIONS (code=exited, status=0/SUCCESS)
Main PID: 55643 (xinetd)
CGroup: /system.slice/xinetd.service
└─55643 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: removing discard
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: removing discard
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: removing echo
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: removing echo
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: removing tcpmux
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: removing time
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: removing time
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: xinetd Version 2.3.15 started with libwrap loadavg labeled-networking option…ed in.
Jan 18 09:59:00 Hortonworks02 xinetd[55643]: Started working: 0 available services
Jan 18 09:59:00 Hortonworks02 systemd[1]: Started Xinetd A Powerful Replacement For Inetd.
Hint: Some lines were ellipsized, use -l to show in full.

测试telnet

[root@Hortonworks02 ~]# telnet localhost
Trying ::1…
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1…
telnet: connect to address 127.0.0.1: Connection refused

并没有连接成功。

查看23端口是否能用

[root@Hortonworks02 ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8010 0.0.0.0:* LISTEN 52726/java
tcp 0 0 0.0.0.0:6188 0.0.0.0:* LISTEN 6119/java
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:19888 0.0.0.0:* LISTEN 56810/java
tcp 0 0 0.0.0.0:10033 0.0.0.0:* LISTEN 56810/java
tcp 0 0 0.0.0.0:4242 0.0.0.0:* LISTEN 53113/jsvc.exec
tcp 0 0 127.0.0.1:41972 0.0.0.0:* LISTEN 52726/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1175/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1785/master
tcp 0 0 0.0.0.0:50010 0.0.0.0:* LISTEN 52726/java
tcp 0 0 0.0.0.0:50075 0.0.0.0:* LISTEN 52726/java
tcp 0 0 0.0.0.0:8670 0.0.0.0:* LISTEN 2229/python
tcp 0 0 0.0.0.0:50079 0.0.0.0:* LISTEN 53113/jsvc.exec
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN 53113/jsvc.exec
tcp 0 0 0.0.0.0:10020 0.0.0.0:* LISTEN 56810/java
tcp 0 0 0.0.0.0:60200 0.0.0.0:* LISTEN 6119/java
tcp6 0 0 :::8042 :::* LISTEN 54539/java
tcp6 0 0 10.0.13.72:6667 :::* LISTEN 4481/java
tcp6 0 0 10.0.13.72:45580 :::* LISTEN 9540/java
tcp6 0 0 :::39692 :::* LISTEN 4481/java
tcp6 0 0 :::45454 :::* LISTEN 54539/java
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 10.0.13.72:3888 :::* LISTEN 2778/java
tcp6 0 0 :::80 :::* LISTEN 995/httpd
tcp6 0 0 :::46386 :::* LISTEN 2778/java
tcp6 0 0 10.0.13.72:39987 :::* LISTEN 9540/java
tcp6 0 0 10.0.13.72:40563 :::* LISTEN 6072/java
tcp6 0 0 10.0.13.72:16020 :::* LISTEN 46355/java
tcp6 0 0 :::42837 :::* LISTEN 6072/java
tcp6 0 0 :::22 :::* LISTEN 1175/sshd
tcp6 0 0 :::7447 :::* LISTEN 54539/java
tcp6 0 0 ::1:25 :::* LISTEN 1785/master
tcp6 0 0 :::13562 :::* LISTEN 54539/java
tcp6 0 0 127.0.0.1:44444 :::* LISTEN 40547/java
tcp6 0 0 :::8765 :::* LISTEN 46639/java
tcp6 0 0 :::61181 :::* LISTEN 6072/java
tcp6 0 0 :::16030 :::* LISTEN 46355/java
tcp6 0 0 :::61310 :::* LISTEN 6072/java
tcp6 0 0 10.0.13.72:41726 :::* LISTEN 6072/java
tcp6 0 0 :::10016 :::* LISTEN 9540/java
tcp6 0 0 :::2181 :::* LISTEN 2778/java
tcp6 0 0 :::8999 :::* LISTEN 5674/java
tcp6 0 0 :::8040 :::* LISTEN 54539/java
tcp6 0 0 :::4040 :::* LISTEN 9540/java
tcp6 0 0 :::7337 :::* LISTEN 54539/java
udp 0 0 127.0.0.1:40 0.0.0.0:* 53113/jsvc.exec
udp 0 0 0.0.0.0:111 0.0.0.0:* 2480/rpcbind
udp 0 0 10.0.13.72:123 0.0.0.0:* 62181/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 62181/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 62181/ntpd
udp 0 0 0.0.0.0:959 0.0.0.0:* 2480/rpcbind
udp 0 0 0.0.0.0:4242 0.0.0.0:* 53113/jsvc.exec
udp6 0 0 :::111 :::* 2480/rpcbind
udp6 0 0 ::1:123 :::* 62181/ntpd
udp6 0 0 fe80::21d:d8ff:feb7:123 :::* 62181/ntpd
udp6 0 0 :::123 :::* 62181/ntpd
udp6 0 0 :::959 :::* 2480/rpcbind

可以看到,tcp并没有23端口。

开放23端口

[root@Hortonworks02 xinetd.d]# firewall-cmd –zone=public –add-port=23/tcp –permanent
success
[root@Hortonworks02 xinetd.d]# firewall-cmd –reload
success

查看修改是否生效

[root@Hortonworks02 xinetd.d]# firewall-cmd –zone=public –query-port=23/tcp
yes

再进行telnet测试

[root@Hortonworks02 xinetd.d]# telnet localhost
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
Kernel 3.10.0-514.el7.x86_64 on an x86_64
Hortonworks02 login: root
Password:
Login incorrect

一直提示密码不正确。
注释/etc/pam.d/remote的第一行

再次测试

[root@Hortonworks02 xinetd.d]# telnet localhost 23
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
Kernel 3.10.0-514.el7.x86_64 on an x86_64
Hortonworks02 login: root
Password:
Last login: Thu Jan 18 10:33:29 from localhost

终于成功了。

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值