如何在centos下開啟telnet服務?
1.查看linux版本資訊:
[loong@localhost ~]$ cat /etc/issue CentOS release 5.8 (Final)Kernel \r on an \m
2. 查看系統是否已安裝telnet-server,linux系統上預設已經安裝telnet -client(或telnet),而telnet-server需要手動安裝。
[loong@localhost ~]$ rpm -qa | grep telnet telnet-0.17-39.el5
3. 安裝telnet-server,若係統已安裝,跳過此步驟。
方法一:下載RPM resource telnet-server
選擇對應版本的telnet-server下載;
安裝: # rpm -i telnet-server-0.17-39.el5.i386.rpm
#看起來還得單獨安裝xinetd.
方法二:(建議使用)
# yum install telnet-server
安裝完成後:
[loong@localhost ~]$ rpm -qa | grep telnet telnet-0.17-39.el5 telnet-server-0.17-39.el5
4. 啟動telnet服務
#方法一:System->Administration->Services 中,
在 On Demand Services
中選取telnet
,
並在Background Services中選取xinetd,並點選上方的Start,即右側顯示:xinetd (pid 15986) is running...
最後Save & Quit.
方法二:編輯/etc/xinetd.d/telnet
, 將其中的 disable = yes
的yes
改為no
.
修改後:
# default: on# description: The telnet server serves telnet sessions; it uses \ # unencrypted username/password pairs for authentication.service telnet
附註:方法二與方法三,需啟動xinetd服務。方法如下:{
disable = no
flags = REUSE
socket_type = stream
= root
server = /usr/sbin/in.telnetd
#
方法三:使用chkconfig指令直接開啟[root@localhost loong]# chkconfig telnet on
[root@localhost loong]# service xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ]或:
[root@localhost loong]# /etc/rc.d/init.d/xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ]5.測試服務
[root@localhost loong]# telnet localhost Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.CentOS release 5.8 (Final)Kernel 2.6.18-308.1.1.el5 on an i686 login: loong Password: Last login: Tue Apr 24 16:42:06 from 10.108.14.135[loong@localhost ~]$ exitlogout Connection closed by foreign host.[root@localhost loong]#
註:預設情況下,系統只允許普通使用者telnet登錄,不允許root用戶登入。
要想取得root權限,可以使用普通使用者登錄,然後執行su,來取得root權限。
# mv /etc/securetty /etc/securetty.bak (不建議此方法,測試完後再改回去吧!)
或先嘗試使用root用戶登錄,不成功,然後查看系統log:
telnet> o localhost Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.CentOS release 5.8 (Final)Kernel 2.6.18-308.1.1.el5 on an i686 login: root Password: Login incorrect login: Login incorrect login: Login incorrect login: Connection closed by foreign host.[root@localhost loong]# tail -20 /var/log/secure Apr 24 17:32:58 localhost login: pam_securetty(remote:auth): access denied: tty 'pts/1' is not secure ! Apr 24 17:33:03 localhost login: FAILED LOGIN 1 FROM localhost FOR root, Authentication failure
可以看到 access denied: tty 'pts/1' is not secure ! 所以将‘pts/1’添加到/etc/securetty中,即可实现telnet的root用户登录。至于为什么?暂不清楚。 方法二:修改/etc/pam.d/remote,注释掉:auth required pam_securetty.so 1 #%PAM-1.02 #auth required pam_securetty.so3 auth include system-auth
註:不建議開放telnet的root登錄,容易帶來安全隱憂。
相關參考:
以上是如何在centos下開啟telnet服務的詳細內容。更多資訊請關注PHP中文網其他相關文章!