分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

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

发布时间:2023-09-06 01:09责任编辑:沈小雨关键词:Linux

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


说明:

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

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

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

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

Telnet定义:

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

安装Telnet:

  1. yum安装telnet和telnet-server

    [root@rhel7 ~]# yum install -y telnet telnet-server

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

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

    [root@ceshiji ~]# vim /etc/xinetd.d/telnet

    设置 disable = no650) this.width=650;" src="https://s3.51cto.com/wyfs02/M02/A4/62/wKioL1mpbj3SxxuqAAAo8e7KM04147.png" title="ww.png" width="600" height="239" border="0" hspace="0" vspace="0" style="width:600px;height:239px;" alt="wKioL1mpbj3SxxuqAAAo8e7KM04147.png" />

    保存并退出文件。

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

    Yum 安装telnet-server区别:

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

    650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/05/B1/wKiom1mpb0CTITcHAAAY2ix15Xw643.png" style="float:none;" title="qqq.png" alt="wKiom1mpb0CTITcHAAAY2ix15Xw643.png" />

    Linux7

    650) this.width=650;" src="https://s1.51cto.com/wyfs02/M00/A4/62/wKioL1mpbymCqzzGAAAavNjRRp4238.png" style="float:none;" title="www.png" alt="wKioL1mpbymCqzzGAAAavNjRRp4238.png" />

  3. 开启telnet服务

    在Linux 6系统中:

    [root@ceshiji ~]# service xinetd start

    在Linux7系统中:

    [root@rhel7 ~]# systemctl start telnet.socket

  4. 开机自启动telnet服务

    在Linux 6系统中:

    [root@ceshiji ~]# chkconfig telnet on

    [root@ceshiji ~]# chkconfig xinetd on

    在Linux7系统中:

    [root@rhel7 ~]# systemctl enable telnet.socket

  5. 查看telnet服务运行状态

    在Linux 6系统中:

    [root@ceshiji ~]# service xinetd status 或 [root@ceshiji ~]# /etc/init.d/xinetd status

    在Linux7系统中:

    [root@rhel7 ~]# service telnet.socket status 或 [root@rhel7 ~]# systemctl status telnet.socket

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

    在Linux 6系统中:

    650) this.width=650;" src="https://s5.51cto.com/wyfs02/M02/05/B1/wKiom1mpdUPSx2v2AAAO2-eyQTU793.png" title="www.png" alt="wKiom1mpdUPSx2v2AAAO2-eyQTU793.png" />

    在Linux 7系统中:

    650) this.width=650;" src="https://s3.51cto.com/wyfs02/M01/A4/62/wKioL1mpdULw15caAAAO2wsBnYc615.png" title="qqq.png" width="645" height="53" border="0" hspace="0" vspace="0" style="width:645px;height:53px;" alt="wKioL1mpdULw15caAAAO2wsBnYc615.png" />

  7. iptables与firewall的配置:

    说明:

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

       [root@ceshiji ~]# iptables -F

       [root@ceshiji ~]# /etc/init.d/iptables stop   

       [root@rhel7 ~]# systemctl stop firewalld

       [root@rhel7 ~]# systemctl disable firewalld

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

       [root@rhel7 ~]# yum install -y iptables-services

       开启iptables服务:

       [root@rhel7 ~]# systemctl start iptables

       查看iptables服务运行状态:

       [root@rhel7 ~]# systemctl status iptables

       开机自启动iptables服务:

       [root@rhel7 ~]# systemctl enable iptables

       使用iptables:

       [root@rhel7 ~]# vim /etc/sysconfig/iptables

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

    650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/A4/99/wKioL1muTCiRupnZAABAj_QxkHo780.png" title="qq.png" alt="wKioL1muTCiRupnZAABAj_QxkHo780.png" />

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

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

       在Linux 6系统中:

       [root@ceshiji ~]# vim /etc/sysconfig/iptables

       加入如下行“-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT”650) this.width=650;" src="https://s5.51cto.com/wyfs02/M02/A4/99/wKioL1muULuwqK-3AABAj_QxkHo262.png" title="qq.png" alt="wKioL1muULuwqK-3AABAj_QxkHo262.png" />

       保存退出!重启iptables服务。     

       [root@ceshiji ~]# service iptables restart

       在Linux 7系统中:

       [root@rhel7 ~]# firewall-cmd --permanent --add-port=23/tcp

       [root@rhel7 ~]# firewall-cmd --reload

  8. 测试

    [root@ceshiji ~]# yum install -y telnet  

    说明:客户端上安装telnet包

    [root@rhel7 ~]# telnet 192.169.5.121

    650) this.width=650;" src="https://s1.51cto.com/wyfs02/M00/05/E9/wKiom1muVaWy1flrAAAoRpp61Os162.png" title="qq.png" alt="wKiom1muVaWy1flrAAAoRpp61Os162.png" />

    完成!



本文出自 “圣骑士控魔之手” 博客,请务必保留此出处http://wutengfei.blog.51cto.com/10942117/1962844

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

原文地址:http://wutengfei.blog.51cto.com/10942117/1962844

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved