思考:
1. 檢測Linux下telnet服務存不存在。
2. 存在則打開,不存在則安裝。
步驟:
1. 使用telnet遠程連接目標主機(本例使用Xshell)
Xshell:\> telnet 192.168.80.218 Connecting to 192.168.80.218:23... Could not connect to '192.168.80.218' (port 23): Connection failed. Type `help' to learn how to use Xshell prompt.
連接失敗
2. 登錄目標主機檢測telnet服務是否正常:telnet localhost
[oracle@localhost ~]$ telnet localhost -bash: telnet: command not found
命令不存在,可以理解爲未安裝該服務。
3. 下一步並不是立即安裝,而是先檢測下該機器中安裝了哪些telnet相關的軟件。多了要刪除,少了要補缺等。
嘗試google:linux telent 服務 等關鍵字。
通過搜索發現telnet由:
telnet-client :telnet客戶端 telnet-server :telnet服務端 xinetd :網絡服務器超級守護進程
大致可以理解爲,大多髮型版本的Linux默認安裝了telnet-client,而telnet-server需要用戶另外安裝。
xinetd是Linux系統的超級守護進程,長期駐存於後臺,並監聽來自網絡的請求,從而啓動對應的服務。而telnet正是xinetd管轄的服務之一。
4. 查詢是否有telnet相關的rpm安裝包:rpm -qa | grep telnet
[root@localhost ~]# rpm -qa | grep telnet telnet-0.17-47.el6.x86_64 [root@localhost ~]#
telnet-0.17-47.el6.x86_64即爲默認安裝的客戶端。很明確的發現,系統確實未默認安裝telnet-server。
5. 使用yum安裝telnet-server服務
yum方式是最爲便捷的在線包安裝工具。
安裝方式都可以直接搜索關鍵字,類似於:
Google:yum telnet
[root@crxjtest xinetd.d]# yum list |grep telnet ... Trying other mirror. telnet.x86_64 1:0.17-47.el6 @anaconda-RedHatEnterpriseLinux-201111171049.x86_64/6.2 telnet-server.x86_64 1:0.17-47.el6 local
發現有telnet-server.x86_64這個源
[root@crxjtest xinetd.d]# yum install telnet-server.x86_64 ... Trying other mirror. Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package telnet-server.x86_64 1:0.17-47.el6 will be installed --> Processing Dependency: xinetd for package: 1:telnet-server-0.17-47.el6.x86_64 --> Running transaction check ---> Package xinetd.x86_64 2:2.3.14-33.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================== Package Arch Version Repository Size =============================================================================================================== Installing: telnet-server x86_64 1:0.17-47.el6 local 37 k Installing for dependencies: xinetd x86_64 2:2.3.14-33.el6 local 120 k Transaction Summary =============================================================================================================== Install 2 Package(s) Total download size: 157 k Installed size: 312 k Is this ok [y/N]: y Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata Package(s) data still to download: 157 k --------------------------------------------------------------------------------------------------------------- Total 1.2 MB/s | 157 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 2:xinetd-2.3.14-33.el6.x86_64 1/2 Installing : 1:telnet-server-0.17-47.el6.x86_64 2/2 Installed products updated. Installed: telnet-server.x86_64 1:0.17-47.el6 Dependency Installed: xinetd.x86_64 2:2.3.14-33.el6 Complete! [root@crxjtest xinetd.d]#
安裝成功。
可再搜索遍看是否已經寫入環境中。
[root@crxjtest xinetd.d]# rpm -qa | grep telnet telnet-0.17-47.el6.x86_64 telnet-server-0.17-47.el6.x86_64
發現telnet-server已經安裝成功。
6. [更改配置文件,將telnet服務設置爲默認啓動,非必須]
查詢xinetd.d所管轄的所有配置文件所在目錄。
[root@crxjtest xinetd.d]# cd /etc/xinetd.d [root@crxjtest xinetd.d]# ls chargen-dgram cvs daytime-stream discard-stream echo-stream tcpmux-server time-dgram chargen-stream daytime-dgram discard-dgram echo-dgram rsync telnet time-stream [root@crxjtest xinetd.d]# vi telnet # default: on # description: The telnet server serves telnet sessions; it uses \ # unencrypted username/password pairs for authentication. service telnet { disable = no flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID }
備份telnet文件,再vi打開,將disable值賦爲no。
7. 開啓telnet服務
[root@crxjtest xinetd.d]# service xinetd restart Stopping xinetd: [FAILED] Starting xinetd: [ OK ]
可直接start,這樣就不會有關閉服務時候報的那個錯,畢竟那個時候服務還不存在。
8. 測試telnet服務
[root@crxjtest xinetd.d]# telnet localhost Trying ::1... Connected to localhost. Escape character is '^]'. Red Hat Enterprise Linux Server release 6.2 (Santiago) Kernel 2.6.32-220.el6.x86_64 on an x86_64 login:
測試正常。
9. 總結
要明確出現的是什麼問題,要有清晰的解決思路,再跟着自己的思路去解決。
本文描述的場景是缺失telnet服務,那能否舉一反三到例如能思考和處理ftp服務缺失的解決呢。
可能的步驟如下:
1. 嘗試使用多種客戶端去連接ftp服務。多次嘗試能避免出現一些低級錯誤,例如是本機客戶端出錯,用戶名密碼錯誤,連接IP端口不對等。嘗試的最後是出一個結果,即是否是ftp服務端出現了問題。
2. 倘若確定是ftp服務端出的問題,則需要登錄該服務器具體處理。在登錄之前,如果不瞭解ftp服務的構成,還需要搜索等方式去了解。
3. 最後就是如何在ftp服務端解決問題。丟東西了,通常的處理方式,就是現在還有哪些東西,還需要安裝哪些東西,最後安裝就好了。
10. 擴展閱讀
Xinetd服務:http://en.wikipedia.org/wiki/Xinetd
linux開啓telnet服務(總結):http://blog.csdn.net/rainbolide/article/details/651853
Windows下開啓telnet服務:http://www.wumingx.cn/post/291.html