1. 程式人生 > >RedHat下開啟ftp,telnet服務,開放root使用者登入telnet

RedHat下開啟ftp,telnet服務,開放root使用者登入telnet

正在學習libcurl庫的使用,想測試下libcurl裡面關於ftp,telnet協議的用法,不過由於安全原因,RedHat 5.3裡面現在已經是預設不開啟ftp和telnet服務了。需要我們自己開啟了。

(一)安裝xinetd

ftp和telnet都是掛在xinetd服務下面,先要看看xinetd有沒有安裝,預設是沒有安裝的。

# rpm -qa | grep xinetd

從執行結果可以看出來,系統預設是沒有安裝xinetd的,首先要安裝xinetd,安裝檔案可以可以在RedHat的安裝CD裡面找到,xinetd-2.3.14-10.el5.i386.rpm。

# rpm -Uvh xinetd-2.3.14-10.el5.i386.rpm


warning: xinetd-2.3.14-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:xinetd                 ########################################### [100%]
[[email protected]_host ~]# rpm -qa | grep xinetd

xinetd-2.3.14-10.el5                           //可以看到已經安裝成功
[[email protected]_host ~]# service xinetd status
xinetd is stopped                               //使用service命令檢視xinetd的狀態,是關閉狀態
[[email protected]_host ~]# service xinetd start
Starting xinetd: [  OK  ]                      //使用service命令開啟xinetd

(二)修改ftp和telnet的配置檔案

/etc/xinetd.d這個目錄下面,儲存的就是掛在xinetd下面各種服務的配置檔案

#cd /etc/xinetd.d/
# ls

chargen-dgram   daytime-dgram   discard-stream  eklogin       klogin       ktalk          time-dgram
chargen-stream  daytime-stream  echo-dgram      ekrb5-telnet  krb5-telnet  rsync          time-stream
cvs             discard-dgram   echo-stream     gssftp        kshell       tcpmux-server

編輯krb5-telnet和gssftp兩個檔案,將disable = yes,改為disable = no,然後重新啟動xinetd,修改配置檔案之後需要重新啟動服務。

# service xinetd restart
Stopping xinetd: [  OK  ]
Starting xinetd: [  OK  ]

(三)“Unencrypted connection refused. Goodbye.”

在/etc/xinetd.d/目錄下面有ekrb5-telnet和krb5-telnet這兩個telnet,有什麼區別呢?ekrb5-telnet是一個加密的telnet服務,假如開啟,則預設telnet是加密的,於是我們登陸的就是就會出現這樣的錯誤,因此需要關閉這個服務,修改/etc/xinetd.d/ekrb5-telnet裡面的disable = yes,然後重新啟動xinetd。

在使用Kerberos 5來認證和加密telnet會話前,需要先搭建一個Kerberos伺服器。

(四)ftp登陸時出現”530 must perform authentication before identifying user”的錯誤提示

修改/etc/xinetd.d/gssftp檔案,將server_args後面的-a刪掉,然後重新啟動xinetd服務。

service ftp
{
    flags       = REUSE
    socket_type = stream
    wait        = no
    user        = root
    server      = /usr/kerberos/sbin/ftpd
    #server_args    = -l -a
    server_args = -l

    log_on_failure  += USERID
    disable     = no
}

(五)開啟root使用者的telnet許可權

(1)確認/etc/pam.d/login中的pam_securetty.so行,並將其註釋掉"#"

[[email protected] /]# vim /etc/pam.d/login
#%PAM-1.0
#auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth       include      system-auth
account    required     pam_nologin.so
account    include      system-auth
password   include      system-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    include      system-auth
session    required     pam_loginuid.so
session    optional     pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the
user context
session    required     pam_selinux.so open
session    optional     pam_keyinit.so force revoke

(2)通telnet控制檯,在/etc/securetty檔案中設定


[[email protected] /]# vim /etc/securetty
console
vc/1
vc/2
vc/3
tty1
tty2
tty3
tty4
tty5
...
pts/0
pts/1
pts/2
pts/3
pts/4

在檔案後面追加"pts/0....pts/n",參考資料上有錯,需要從pts/0開始新增,假如需要登陸的人很多,後面的n就要比較大,否則超過了也將無法登陸。