安装telnet服务

#环境

  • os: OpenSUSE Tumbleweed
  • pc: Thinkpad T460s

#描述

远程登陆方式主要有三种:

1 明文文本模式:telnet,rsh等,不安全,现在很少使用,但在一些特殊场所还会有所使用。
2 加密文本模式:ssh
3 图形模式:xdmcp,vnc,rdp等

1.查询系统中是否已经安装了telnet服务

1
[root@ovirt ~]# rpm -qa |grep telnet

2.安装telnet-server服务端及telnet客户端包

1
[root@ovirt ~]# yum install telnet-server talnet

3.telnet服务是由xinetd守护进程维护的,需要启动xinetd服务

1
[root@ovirt ~]# yum install xinetd

4.rhel7版本使用systemd代替init.d维护启动进程,7版本以下使用init.d管理

1
[root@ovirt ~]# systemctl start xinetd

7版本以下修改/etc/xinetd.d/telnet

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@hostovirt ~]# vi /etc/xinetd.d/telnet 
# default: on
# description: The telnet server serves telnet 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 # 这个配置项由yes修改为no
[root@ovirt ~]# service xinetd start

5.启动telnet-server,7版本使用systemd,7版本以下使用init.d启动xinetd后会自动启动telnet

1
[root@ovirt etc]# systemctl start telnet.socket

6.防火墙开放端口

1
2
[root@ovirt etc]# firewall-cmd --zone=public --add-port=23/tcp
success

iptables操作方法:

1
2
3
[root@hostovirt ~]# iptables -I INPUT -p tcp --dport 23 -j ACCEPT
[root@ovirt etc]# firewall-cmd --zone=public --list-ports
23/tcp

7.使用nmap查看端口状态,STATE为open状态

1
2
3
4
5
6
7
8
9
haotianfei@tianfei-opensuse:~> nmap 192.168.56.101 -p 23
Starting Nmap 7.70 ( https://nmap.org ) at 2018-10-11 14:41 CST
Nmap scan report for ovirt.wasu (192.168.56.101)
Host is up (0.00037s latency).

PORT STATE SERVICE
23/tcp filtered telnet

Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
1
2
3
4
5
6
7
8
9
haotianfei@tianfei-opensuse:~> nmap 192.168.56.101 -p 23
Starting Nmap 7.70 ( https://nmap.org ) at 2018-10-11 14:43 CST
Nmap scan report for ovirt.wasu (192.168.56.101)
Host is up (0.00032s latency).

PORT STATE SERVICE
23/tcp open telnet

Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds

8.出于安全原因,默认telnet终端是不能登陆的,暂时移除/etc/securetty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
haotianfei@tianfei-opensuse:~> telnet -l root 192.168.56.101
Trying 192.168.56.101...
Connected to 192.168.56.101.
Escape character is '^]'.
Password:
Login incorrect

ovirt login:
[root@ovirt etc]# mv /etc/securetty{,.bak}
haotianfei@tianfei-opensuse:~> telnet -l root 192.168.56.101 23
Trying 192.168.56.101...
Connected to 192.168.56.101.
Escape character is '^]'.
Password:
Last failed login: Thu Oct 11 02:44:46 EDT 2018 from ::ffff:192.168.56.1 on pts/1
There were 3 failed login attempts since the last successful login.
Last login: Thu Oct 11 02:35:13 from ::ffff:192.168.56.1
[root@ovirt ~]#
坚持原创技术分享,您的支持将鼓励我继续创作!