一、安装telnet
1、检测telnet-server的rpm包是否安装 [root@localhost ~]# rpm -qa telnet-server
若无输入内容,则表示没有安装。出于安全考虑telnet-server.rpm是默认没有安装的,而telnet的客户端是标配。即下面的软件是默认安装的。
2、若未安装,则安装telnet-server,否则忽略此步骤
[root@localhost ~]#yum install telnet-server
3、检测telnet-server的rpm包是否安装
[root@localhost ~]# rpm -qa telnet
telnet-0.17-47.el6_3.1.x86_64
4、若未安装,则安装telnet,否则忽略此步骤
[root@localhost ~]# yum install telnet
二、检查是否安装xinetd
[root@localhost ~]#rpm -qa | grep xinetd
若未安装,则安装xinetd,否则忽略此步骤
yum -y install xinetd
三、telnet服务安装之后,默认是不开启服务,修改文件/etc/xinetd.d/telnet来开启服务
注:第一次修改,此文件若不存在,可自己vim创建修改:修改 disable = yes 为 disable = no
[root@Solin xinetd.d]# pwd
/etc/xinetd.d
[root@Solin xinetd.d]# ls
chargen-dgram daytime-stream echo-dgram time-dgram
chargen-stream discard-dgram echo-stream time-stream
daytime-dgram discard-stream tcpmux-server
[root@Solin xinetd.d]# vim telnet
[root@Solin xinetd.d]# cat 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
}
四、启动telnet和依赖的xinetd服务
[root@Solin xinetd.d]# systemctl restart xinetd.service
[root@Solin xinetd.d]# ps -ef | grep xinetd #查看xinetd是否启动
root 6100 1 0 10:20 ? 00:00:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
root 6159 3770 0 10:21 pts/1 00:00:00 grep --color=auto xinetd
[root@Solin xinetd.d]# ps -ef | grep telnet #查看telnet是否启动
root 6239 3770 0 10:22 pts/1 00:00:00 grep --color=auto telnet
五、测试
我们先来查看TCP的23端口是否开启正常
[root@localhost ~]#netstat -tnl |grep 23
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
如果上面的一行存在就说明服务已经运行了。如果netstat命令没有返回内容,我们就只好继续进行更深入的配置了。
在windows下打开cmd命令行窗口,输入telnet 192.168.1.10 回车,然后输入用户名密码
六、设置服务开机启动
将xinetd服务加入开机自启动:systemctl enable xinetd.service
将telnet服务加入开机自启动:systemctl enable telnet.socket