在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet


说明:

在安装和使用Telnet之前,需要记住以下几点。

  • 在公网(WAN)中使用Telnet是非常不好的想法。它会以明文的格式传输登入数据。每个人都可以看到明文。

  • 如果你还是需要Telnet,强烈建议你只在局域网内部使用。

  • 你可以使用SSH作为替代方法。但是确保不要用root用户登录。

Telnet定义:

Telnet 是用于通过TCP/IP网络远程登录计算机的协议。一旦与远程计算机建立了连接,它就会成为一个虚拟终端且允许你与远程计算机通信。

安装Telnet:

  1. yum安装telnet和telnet-server

    [[email protected] ~]# yum install -y telnet telnet-server

    现在telnet已经安装在你的服务器上了。

  2. 编辑文件/etc/xinetd.d/telnet

    [[email protected] ~]# vim /etc/xinetd.d/telnet

    设置 disable = no在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

    保存并退出文件。

    说明:我们不必在Linux 7做这步,原因如下图:

    Yum 安装telnet-server区别:

    Linux6安装telnet-server时有xinetd依赖包被安装,而Linux7并没有xinetd依赖包被安装!

    在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

    Linux7

    在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

  3. 开启telnet服务

    在Linux 6系统中:

    [[email protected] ~]# service xinetd start

    在Linux7系统中:

    [[email protected] ~]# systemctl start telnet.socket

  4. 开机自启动telnet服务

    在Linux 6系统中:

    [[email protected] ~]# chkconfig telnet on

    [[email protected] ~]# chkconfig xinetd on

    在Linux7系统中:

    [[email protected] ~]# systemctl enable telnet.socket

  5. 查看telnet服务运行状态

    在Linux 6系统中:

    [[email protected] ~]# service xinetd status 或 [[email protected] ~]# /etc/init.d/xinetd status

    在Linux7系统中:

    [[email protected] ~]# service telnet.socket status 或 [[email protected] ~]# systemctl status telnet.socket

  6. telnet默认的端口是23,查看侦听端口

    在Linux 6系统中:

    在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

    在Linux 7系统中:

    在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

  7. iptables与firewall的配置:

    说明:

    (1)如果不使用iptables与firewall可以将它们关闭,关闭的命令如下:

       [[email protected] ~]# iptables -F

       [[email protected] ~]# /etc/init.d/iptables stop   

       [[email protected] ~]# systemctl stop firewalld

       [[email protected] ~]# systemctl disable firewalld

    (2)Linux7中不再有iptables,使用firewalld;在Linux7中安装并使用iptables的方法如下:

       [[email protected] ~]# yum install -y iptables-services

       开启iptables服务:

       [[email protected] ~]# systemctl start iptables

       查看iptables服务运行状态:

       [[email protected] ~]# systemctl status iptables

       开机自启动iptables服务:

       [[email protected] ~]# systemctl enable iptables

       使用iptables:

       [[email protected] ~]# vim /etc/sysconfig/iptables

       加入如下行“-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT”

    在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

    说明:上面只是演示下linux7中iptables安装和使用,实际工作中在linux7中,我们使用的是firewall!

    (3)开启iptables和firewall,让telnet的默认端口23可以通过防火墙和路由器。

       在Linux 6系统中:

       [[email protected] ~]# vim /etc/sysconfig/iptables

       加入如下行“-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT”在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

       保存退出!重启iptables服务。     

       [[email protected] ~]# service iptables restart

       在Linux 7系统中:

       [[email protected] ~]# firewall-cmd --permanent --add-port=23/tcp

       [[email protected] ~]# firewall-cmd --reload

  8. 测试

    [[email protected] ~]# yum install -y telnet  

    说明:客户端上安装telnet包

    [[email protected] ~]# telnet 192.169.5.121

    在CentOS/RHEL/Scientific Linux 6 & 7 上安装Telnet

    完成!




     本文转自品鉴初心51CTO博客,原文链接:http://blog.51cto.com/wutengfei/1962844,如需转载请自行联系原作者