Linux上的telnet服务器

时间:2020-03-21 11:47:23  来源:igfitidea点击:

尽管telnet是一种不赞成使用的方法,用于远程登录,但直到今天,它仍用于测试目的和Linux领域的其他演示。
在本文中,我们将引导我们完成在Redhat Linux机器上安装和配置telnet服务器的步骤。

我们在本教程中使用的redhat版本是Red Hat Linux 5.4.

我们将使用YUM软件包管理工具来安装它。

使用YUM进行安装的主要优点是,它可以很好地自行处理依赖关系问题。

[root@theitroad ~]# yum install telnet*
Loaded plugins: rhnplugin, security
Repository 'theitroad' is missing name in configuration, using id
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Package 1:telnet-0.17-39.el5.i386 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.i386 1:0.17-39.el5 set to be updated
--> Finished Dependency Resolution

步骤2:Linux中的Telnet配置文件

#vim /etc/xinetd.d/telnet
service telnet
{
       flags          = REUSE
       socket_type    = stream
       wait           = no
       user           = root
       server         = /usr/sbin/in.telnetd
       log_on_failure += USERID
       disable        = no
}

保存并退出
注意:在上面的文件中,我们仅作了一次更改,也就是说,我们写disable = no代替了yes。

步骤3:重新启动xinetd服务

#service xinetd restart
#chkconfig xinetd on

步骤4:立即从telnet客户端电脑检查telnet设置。

$telnet 192.168.1.1

192.168.1.1是telnet服务器的IP地址。

如果发现任何问题,请使用以下命令刷新iptables规则。

#iptables -F

并禁用SELinux策略

[root@theitroad ~]# setenforce 0
setenforce: SELinux is disabled

步骤5:现在通过telneting theitroad.com主机检查telnet登录

[root@theitroad ~]# telnet theitroad.com
Trying 192.168.1.1...
Connected to theitroad.com (192.168.1.1).
Escape character is '^]'.
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Kernel 2.6.18-164.el5 on an i686

如何检查特定用户的telnet支持命令。

[root@localhost ~]# telnet -l [email protected]
telnet> help

如何使用telnet通过站点进行连接?

telnet> open theitroad.com
Trying 199.79.62.54...

如何使用telnet命令通过特定用户登录?

[root@localhost ~]# telnet -l [email protected]
telnet> open 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1 (192.168.1.1).
Escape character is '^]'.
Password:
Login incorrect
login: theitroad
Last login: Wed Apr 24 00:54:13 from 192.168.1.1
[theitroad@localhost ~]$whoami
theitroad
[theitroad@localhost ~]$

如何使用display命令?

telnet>display

如何设置telnet模式?

telnet>mode

TELNET服务器不安全

Telnet用于远程登录。
登录时,登录名和密码为明文格式。
因此,如果有人使用wireshark之类的工具来追踪我们的连接,那么他/她就可以轻松地查看数据以及登录ID和密码。
甚至远程用户也可以通过简单的方式轻松地找到telnet端口是否已打开nmap命令。

[root@localhost test]# nmap 192.168.1.1
Starting Nmap 4.11 ( http://www.insecure.org/nmap/) at 2013-04-24 01:27 EDT
Interesting ports on 192.168.1.1:
Not shown: 1673 closed ports
PORT      STATE SERVICE
23/tcp    open  telnet
79/tcp    open  finger
111/tcp   open  rpcbind

Nmap finished: 1 IP address (1 host up) scanned in 0.463 seconds

因此,可以清楚地看到telnet的端口已打开。
因此,他或者她现在可以尝试在此计算机上进行远程登录,并获取远程登录的用户名和密码,从而可以使用wireshark。

如果我们正在使用UBUNTU:

#apt-get update
#apt-get install wireshark tshark

如果我们使用的是Rhel,Fedora或者CentOS:

root@localhost test]# yum install wireshark*

那么当我们发现系统中没有使用telnet时该怎么办?

  • 检查telnet配置文件(/etc/xinetd.d/telnet)并将“禁用”选项设置为“是”。
  • 检查另一个文件(该文件是可选文件)以配置telnet(/etc/xinetd.d/krb5-telnet),然后在此处还将“禁用”选项也设置为“是”。
  • 我们也可以通过防火墙禁用telnet。
  • Tcpwrapper也可以用于阻止telnet服务。
  • 禁用telnet服务'[root @ theitroad~]#service xinetd stop'
  • '* [root @ theitroad~]#chkconfig xinetd关闭'
  • 我们还可以删除telnet服务器软件包。
  • “ [root @ theitroad~]#yum删除telnet服务器---- >>这将卸载telnet服务器”

我们将如何配置telnet以进行安全的远程登录?

我们将如何使用xinetd的灵活性来以优化方式和安全方式来控制其资源使用量?

如今,为远程登录配置telnet并不是一个好主意。
但是,如果要求我们实现telnet进行安全登录,则仍然可以通过为它应用一些安全级别来使Telent安全。

我们可以将telnet与Kerberose Server绑定在一起以使Telnet安全。

如何通过在自定义端口上进行配置来使Telnet服务器安全?

安全的Tenet服务器配置:

步骤1:将telnet配置文件复制到另一个文件名stelnet。

[root@localhost ~]# cp /etc/xinetd.d/telnet /etc/xinetd.d/stelnet

步骤2:现在在配置文件/etc/xinetd.d/stelnet中进行更改,

并将服务从telnet更改为stelnet,从yest no更改disable并手动添加端口号,此处为8888.

service stelnet
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.telnetd
        log_on_failure  += USERID
        disable         = no
        port            =8888
}

第三步:现在手动将端口号添加到linux机器上,并通知他们我们将把它用于telnet。

转到/etc/services文件并输入。

stelnet         8888/tcp                        #secure telnet port
tcpmux          1/tcp                           # TCP port service multiplexer
tcpmux          1/udp                           # TCP port service multiplexer

步骤4:进行上述更改后,重新启动xinetd服务。

[root@localhost ~]# service xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]

步骤5:现在通过新分配的端口测试telnet登录。

[root@theitroad ~]# telnet theitroad.com 25
Trying 1.1.1.1...
Connected to theitroad.com (1.1.1.1).
Escape character is '^]'.
220 theitroad.com ESMTP Sendmail 8.13.8/8.13.8; Wed, 12 Nov 2014 12:14:49 +0530
ehlo theitroad
250-theitroad.com Hello theitroad.com [1.1.1.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
mail from:[email protected]
rcpt to:[email protected]
data
hey shivangi I love You!                                    
howz your classes going on?
have you got admission in LMNIT?
.
250 2.1.0 [email protected]... Sender ok
250 2.1.5 [email protected]... Recipient ok
354 Enter mail, end with "." on a line by itself
250 2.0.0 s1C6inOC015669 Message accepted for delivery
quit

解释:

在theitroad.com上。

root和shivangi是theitroad.com计算机上的两个用户。

root希望使用telnet和smtp端口向用户shivangi发送邮件。

邮件来自:[email protected],这意味着root是发件人,并且在theitroad.com上

rcpt到:[email protected],这意味着数据或者邮件将发送到也位于theitroad.com上的用户shivangi。

数据只能在键入数据后才能写入任何内容,否则不能写入。


(。)点用于指定现在我们没有更多数据可写入或者发送。

quit此命令告诉将邮件发送回终端后退出。

如何使用telnet从收件箱或者邮件服务器接收或者检索邮件。(Telnet + pop3)

其中我们将学习如何使用telnet检索电子邮件。由于telnet与端口110结合使用时,它的工作方式类似于pop3协议,并且能够阻止收件箱中的邮件。

现在了解如何检索或者读取root用户发送的消息。
在同一台计算机上,我们在端口110上进行telnet,该端口为pop3端口。

众所周知,POP使用TCP端口110.

POP3在TCP端口995上使用SSL加密。

其中我们将使用端口110,这意味着不支持SSL。

[root@theitroad ~]# telnet theitroad.com 110
Trying 1.1.1.1...
Connected to theitroad.com (1.1.1.1).
Escape character is '^]'.
+OK Dovecot ready.
user shivangi
+OK
pass shivangi
+OK Logged in.
stat
+OK 1 412
list
+OK 1 messages:
1 412
.
retr 1
+OK 412 octets
Return-Path: <[email protected]>
Received: from theitroad (theitroad.com [1.1.1.1])
        by theitroad.com (8.13.8/8.13.8) with ESMTP id s1C6inOC015669
        for [email protected]; Wed, 12 Nov 2014 12:17:04 +0530
Date: Wed, 12 Nov 2014 12:14:49 +0530
From: root <[email protected]>
Message-Id: <[email protected]>
hey shivangi I love You!
howz your classes going on?
have you got admission in LMNIT?
.
quit

解释:

用户shivangi定义我们要登录和阅读的用户的名称。

通过shivangi这意味着以上用户的密码是shivangi。

列表显示收件箱中的邮件或者邮件列表

retr 1表示转到并打开或者检索邮件1.

。点表示任务已结束,我们已经准备好从这里开始。

完成所有操作后,从此处退出。