1、安装软件
1)、检查是否已安装 telnet
需要安装的软件有三个:
telnet-server:telnet 服务端
xinetd:telnet 的自启动依赖它
安装之前先检测是否已安装了这些软件包:
[root@showayCentOS ~]# rpm -qa|grep telnet // 检查是否安装了 telnet
[root@showayCentOS ~]# rpm -qa|grep xinetd // 检查是否安装了 xinetd
[root@showayCentOS ~]#
如上所示,执行结果没有输出,表明该服务器上没有安装 telnet 和 xinetd。
2)、安装 telnet 及 xinetd
查询可以安装的 telnet 和 xinetd 程序包:
[root@showayCentOS ~]# yum list|grep telnet // 显示所有已安装和可安装的程序包
telnet.x86_64 1:0.17-64.el7 base // 客户端,可以安装以方便自测
telnet-server.x86_64 1:0.17-64.el7 base // base 表示可安装
[root@showayCentOS ~]# yum list|grep xinetd
xinetd.x86_64 2:2.3.15-13.el7 base
安装 telnet 服务端 和 xinetd(程序名在上面可以看到):
[root@showayCentOS ~]# yum install -y telnet-server // 安装 telnet 服务端
...
...
...
已安装:
telnet-server.x86_64 1:0.17-64.el7
完毕!
[root@showayCentOS ~]# yum install -y xinetd // 安装 xinetd
...
...
...
已安装:
xinetd.x86_64 2:2.3.15-13.el7
完毕!
安装 telnet 客户端(选装,安装上可以方便自测 telnet 服务是否正常启动):
[root@showayCentOS ~]# yum install -y telnet
...
...
...
已安装:
telnet.x86_64 1:0.17-64.el7
完毕!
3)、设置开机自启动并开启服务
设置开机自启动(为了防止服务器意外重启):
[root@showayCentOS ~]# systemctl enable xinetd.service // 开机启动 xinetd 服务
[root@showayCentOS ~]# systemctl enable telnet.socket // 开机启动 telnet 服务
Created symlink from /etc/systemd/system/sockets.target.wants/telnet.socket to /usr/lib/systemd/system/telnet.socket.
开启服务:
[root@showayCentOS ~]# systemctl start telnet.socket
[root@showayCentOS ~]# systemctl start xinetd.service
查看 telnet 和 xinetd 服务状态:
[root@showayCentOS ~]# 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 四 2019-12-19 23:16:14 CST; 12s ago
Process: 15846 ExecStart=/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid $EXTRAOPTIONS (code=exited, status=0/SUCCESS)
Main PID: 15847 (xinetd)
CGroup: /system.slice/xinetd.service
└─15847 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
12月 19 23:16:14 showayCentOS xinetd[15847]: removing discard
12月 19 23:16:14 showayCentOS xinetd[15847]: removing discard
12月 19 23:16:14 showayCentOS xinetd[15847]: removing echo
12月 19 23:16:14 showayCentOS xinetd[15847]: removing echo
12月 19 23:16:14 showayCentOS xinetd[15847]: removing tcpmux
12月 19 23:16:14 showayCentOS xinetd[15847]: removing time
12月 19 23:16:14 showayCentOS xinetd[15847]: removing time
12月 19 23:16:14 showayCentOS xinetd[15847]: xinetd Version 2.3.15 started with libwrap loadavg labeled-networking options compiled in.
12月 19 23:16:14 showayCentOS xinetd[15847]: Started working: 0 available services
12月 19 23:16:14 showayCentOS systemd[1]: Started Xinetd A Powerful Replacement For Inetd.
[root@showayCentOS ~]# systemctl status telnet.socket
● telnet.socket - Telnet Server Activation Socket
Loaded: loaded (/usr/lib/systemd/system/telnet.socket; enabled; vendor preset: disabled)
Active: active (listening) since 四 2019-12-19 23:15:58 CST; 8min ago
Docs: man:telnetd(8)
Listen: [::]:23 (Stream)
Accepted: 1; Connected: 0
12月 19 23:15:58 showayCentOS systemd[1]: Listening on Telnet Server Activation Socket.
可以看到,xinetd 和 telnet 服务都已成功启动(每个命令执行结果的第三行)。