Centos下telnet的安裝和配置


網上摘錄的留着自己有用!

摘自:http://blog.sina.com.cn/s/blog_53ec9d910101pmi0.html#post

 

vista或windows 7的系統默認安裝是沒有安裝這個組件的,你需要安裝一下,這樣操作: 控制面板 ->程序和功能 ->打開或關閉windows功能 ->把telnet客戶端打勾 ->確定即可. 
  
一.查看本機是否有安裝telnet  # rpm -qa |grep telnet   
如果顯示結果為: 
telnet-server-0.17-47.el6_3.1.i686  
那恭喜你,機器上已經安裝了telnet。如果沒有安裝,請看下一步。   
特別說明: 
telnet分為telnet-client (簡稱為telnet)和telnet-server。    
二、安裝telnet 
第一種方法(在線安裝): 可使用命令: 
#yum install xinetd (注意在root下安裝) 
#yum install telnet-server(注意在root下安裝) 

[root@bogon xinetd.d]# yum list   telnet-server

Loading "installonlyn" plugin

Setting up repositories

Reading repository metadata in from local files

Available Packages

telnet-server.i386                       1:0.17-39.el5          base           

[root@bogon xinetd.d]# yum install telnet-server

Loading "installonlyn" plugin

Setting up Install Process

Setting up repositories

Reading repository metadata in from local files

Parsing package install arguments

Resolving Dependencies

--> Populating transaction set with selected packages. Please wait.

---> Downloading header for telnet-server to pack into transaction set.

telnet-server-0.17-39.el5 100% |=========================| 8.4 kB    00:01    

---> Package telnet-server.i386 1:0.17-39.el5 set to be updated

--> Running transaction check

 

Dependencies Resolved

 

=============================================================================

Package                 Arch       Version          Repository        Size

=============================================================================

Installing:

telnet-server           i386       1:0.17-39.el5    base               35 k

 

Transaction Summary

=============================================================================

Install      1 Package(s)        

Update       0 Package(s)        

Remove       0 Package(s)        

 

Total download size: 35 k

Is this ok [y/N]: y 選程Yes

Downloading Packages:

(1/1): telnet-server-0.17 100% |=========================| 24 kB    00:31    

http://ftp.stu.edu.tw/Linux/CentOS/5.2/os/i386/CentOS/telnet-server-0.17-39.el5.i386.rpm: [Errno 4] Socket Error: timed out

Trying other mirror.

http://centos.cs.nctu.edu.tw/5.2/os/i386/CentOS/telnet-server-0.17-39.el5.i386.rpm: [Errno 4] IOError:

Trying other mirror.

(1/1): telnet-server-0.17 100% |=========================| 35 kB    00:00    

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: telnet-server                ######################### [1/1]

 

Installed: telnet-server.i386 1:0.17-39.el5

Complete!

 

3、修改配置文件vi /etc/xinetd.d/telnet

 

[root@bogon xinetd.d]# more 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           = yes

}

將disable項由yes改成no。

4、重啟服務生效

/etc/init.d/xinetd restart

  
第二種方法(光盤安裝法): cd /光盤/CentOS 
rpm -ivh xinetd-2.3.14-10.el5.i386.rpm 
rpm -ivh telnet-server-0.17-47.el6.3.1.i686.rpm   
特別說明: 1、telnet服務要依靠xinetd服務啟動,所以要先安裝xinetd服務。所以我們要先安裝xinetd,再安裝telnet-server。CentOS6.4默認沒有安裝telnet和xinetd服務。 
2、CentOS-6.4-i386-bin-DVD里面有xinetd和telnet-server和安裝包!!不需要上網下載!!       
三.配置telnet 方法一:使用ntsysv(要在root下),在出現的窗口之中,將 telnet 勾選起來,然后按下 OK 即可! 
  
方法二:使用chkconfig命令直接開啟 

 

 


#chkconfig telneton   
方法三:直接修改配置文件 vi /etc/xinetd.d/telnet   
一般是這樣子的: 
# default: yes 
# description: The telnet server servestelnet 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         = yes }   
只需要將”disable= yes”改成” disable=no” 
      
四、激活服務 
 查看服務運行的狀態                                  

#service  xinetd  status  啟動telent服務                                              

#service  xinetd  start 查看該服務開機自啟動情況                     

#chkconfig --list xinetd  
設置該服務在3和5級別運行的時候開機自啟動          

#chkconfig ---level  35 xinetd on 

設置好之后顯示如下: 
 xinetd 0:關閉 1:關閉 2:關閉 3:啟用 4:關閉 5:啟用 6:關閉 
 
telnet 是掛在xinetd 底下的,所以自然只要重新激活xinetd 就能夠將xinetd 里頭的設定重新讀進來,所以剛剛設定的 telnet 自然 也就可以被激活。 
  # servicexinetd restart 
或者#/etc/rc.d/init.d/xinetd restart 
    
五.iptables防火牆會阻止telnet,所以需要在iptables允許,用如下命令 
  
當你啟動telnet服務后,你可以用netstat –tunlp命令來查看telnet服務所使用的端口,可以發現有23。使用下面命令開啟這些端口:   

 

 


iptables -I INPUT -p tcp --dport 23 -jACCEPT   
iptables -I INPUT -p udp --dport 23 -jACCEPT   
service iptables save  //保存   
service iptables restart //重啟防火牆   
或者來點狠的!!關閉防火牆!   
serviceiptables stop     
六、可能的問題: 
下面我們來看一下二種錯誤: 第一種: 
[root@linuxchao ~]# telnet 192.168.1.87 Trying 192.168.1.87... 
telnet: connect to address 192.168.1.87: Noroute to host telnet: Unable to connect to remote host:No route to host   
解決方法:這種問題防火牆沒有允許telnet服務,連接被阻止,默認CentOS只允許SSH,所以進入其自定義選項,在telnet前打個勾!   
第二種 
   [root@testxinetd.d]# telnet 172.25.1.3   Trying 172.25.1.3... 
  Connected to 172.25.1.3 (172.25.1.3).   Escape character is '^]'. 
  getnameinfo: localhost: Success 
  Temporary failure in name resolution: Illegal seek   Connection closed by foreign host.   
這一個就是/etc/hosts文件配置問題 
解決方法:我在里面加兩個IP地址,內容如下: 
  
 [linux@localhost ~]$ more /etc/hosts 
# Do not remove the following line, orvarious programs # that require network functionality willfail. 127.0.0.1localhost.localdomainlocalhost ::1localhost6.localdomain6localhost6 192.168.1.88 192.168.1.86 
說明:因為客戶機的名字不好記就沒寫進去,內容格式應為127.0.0.1 pcnamer 

 

 


Remove: 
root@centos5 /]# cat /etc/redhat-release  CentOS release 5 (Final) 
[root@centos5 /]# rpm -qa | grep telnet telnet-0.17-38.el5 
[root@centos5 /]# rpm -qa telnet telnet-0.17-38.el5 
[root@centos5 /]# rpm -ql telnet /usr/bin/telnet 
/usr/share/man/man1/telnet.1.gz [root@centos5 /]#   
[root@centos5 /]# rpm -e telnet-0.17-38.el5 [root@centos5 /]# rpm -qa telnet [root@centos5 /]#   
上面幾個命令,你就基本能知道你軟件的情況了。用rpm -e 就可以卸載軟件。  
如果查詢rpm包的安裝路徑,這個問題大家經常問。 
 
rpm -ql telnet   
就可以知道這個軟件,安裝在那里,等卸載完,再去看看,是否真的沒有了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM