安装telnet-server
[root@ ~]# yum -y install xinetd telnet-server <p>#离线安装命令:rpm -ivh xinetd-2.3.15-14.el7.x86_64.rpm telnet-server-0.17-65.el7_8.x86_64.rpm
配置telnet
先看一下xinetd.d目录下是否有telnet文件
[root@ ~]# ll /etc/xinetd.d/telnet ls: cannot access /etc/xinetd.d/telnet: No such file or directory
如果有,则将文件里面的disable = no改成disable = yes
如果没有,就进行下面的操作
[root@ ~]# cat > /etc/xinetd.d/telnet <<EOF service telnet { disable = yes flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID } EOF
配置telnet登录的终端类型
[root@ ~]# cat >> /etc/securetty <<EOF pts/0 pts/1 pts/2 pts/3 EOF
启动telnet服务
[root@ ~]# systemctl enable xinetd --now [root@ ~]# systemctl enable telnet.socket --now [root@ ~]# ss -nltp | grep 23 LISTEN 0 128 :::23 :::* users:(("systemd",pid=1,fd=46))
23端口起来了,表示telnet服务正常运行
关闭telnet服务(有两种方式)
vi /etc/xinetd.d/telnet,将disable=no改成disable=yes;
chkconfig telnet off 停止开机自启,使用命令chkconfig -del telnet或者chkconfig --del telnet 删除开机自启。telnet服务关闭开机自启
vi /etc/services,注释23号端口
service xinetd stop 关闭 xinetd 服务以停止telnet服务