天天看點

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

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

說明:

在安裝和使用Telnet之前,需要記住以下幾點。

在公網(WAN)中使用Telnet是非常不好的想法。它會以明文的格式傳輸登入資料。每個人都可以看到明文。

如果你還是需要Telnet,強烈建議你隻在區域網路内部使用。

你可以使用SSH作為替代方法。但是確定不要用root使用者登入。

Telnet定義:

安裝Telnet:

yum安裝telnet和telnet-server

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

現在telnet已經安裝在你的伺服器上了。

編輯檔案/etc/xinetd.d/telnet

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

儲存并退出檔案。

說明:我們不必在Linux 7做這步,原因如下圖:

Yum 安裝telnet-server差別:

Linux6安裝telnet-server時有xinetd依賴包被安裝,而Linux7并沒有xinetd依賴包被安裝!

<a href="https://s2.51cto.com/wyfs02/M02/05/B1/wKiom1mpb0CTITcHAAAY2ix15Xw643.png" target="_blank"></a>

<a href="https://s1.51cto.com/wyfs02/M00/A4/62/wKioL1mpbymCqzzGAAAavNjRRp4238.png" target="_blank"></a>

開啟telnet服務

在Linux 6系統中:

[root@ceshiji ~]# service xinetd start

在Linux7系統中:

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

開機自啟動telnet服務

[root@ceshiji ~]# chkconfig telnet on

[root@ceshiji ~]# chkconfig xinetd on

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

檢視telnet服務運作狀态

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

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

telnet預設的端口是23,檢視偵聽端口

<a href="https://s5.51cto.com/wyfs02/M02/05/B1/wKiom1mpdUPSx2v2AAAO2-eyQTU793.png" target="_blank"></a>

在Linux 7系統中:

<a href="https://s3.51cto.com/wyfs02/M01/A4/62/wKioL1mpdULw15caAAAO2wsBnYc615.png" target="_blank"></a>

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”

<a href="https://s4.51cto.com/wyfs02/M00/A4/99/wKioL1muTCiRupnZAABAj_QxkHo780.png" target="_blank"></a>

(3)開啟iptables和firewall,讓telnet的預設端口23可以通過防火牆和路由器。

   在Linux 6系統中:

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

   儲存退出!重新開機iptables服務。     

   [root@ceshiji ~]# service iptables restart

   在Linux 7系統中:

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

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

測試

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

說明:用戶端上安裝telnet包

[root@rhel7 ~]# telnet 192.169.5.121

<a href="https://s1.51cto.com/wyfs02/M00/05/E9/wKiom1muVaWy1flrAAAoRpp61Os162.png" target="_blank"></a>

完成!

     本文轉自品鑒初心51CTO部落格,原文連結:http://blog.51cto.com/wutengfei/1962844,如需轉載請自行聯系原作者

繼續閱讀