最近剛學Linux,想要在Linux上配置一個ftp伺服器,就用源碼編譯安裝了一個2.1.2版本的vsftpd。安裝過程還好,在配置的過程中就遇到了一些問題,以下配置過程及解決方案:
1.方法一:
先建立一個系統使用者,然後修改/etc/passwd檔案
命令如下(mytest是使用者名稱):
#先建立一個系統使用者並設定密碼
[root@localhost home]#useradd mytest
[root@localhost home]#passwd mytest
[root@localhost home]# passwd mytest
Changing password for user mytest.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
這樣設定後的使用者有系統許可權,通過下面的方法來去除使用者的系統許可權
#修改/etc/passwd檔案[root@localhost etc]# cd /etc[root@localhost etc]# vi passwd#找到剛才添加的使用者(mytest)並修改如下,之前要確保檔案夾/home/mytest已存在mytest:x:501:50:Test ftp user:/home/mytest/:/sbin/nologin其中,mytest表示使用者名稱;x表示加密;500表示UID;50表示GID,這裡50表示FTP組;Test ftp user表示對使用者的說明;/home/testftp表示使用者的主目錄;/bin/nologin表示不能登入系統。方法二:直接使用命令:[root@localhost etc]# useradd -d /home/mytest/ -g ftp -s /sbin/nologin mytest這樣新使用者就建立好了。不過,我在建立好使用者後登陸時出現如下的提示:[root@localhost etc]# ftp localhostConnected to localhost.localdomain.220 (vsFTPd 2.0.5)530 Please login with USER and PASS.530 Please login with USER and PASS.KERBEROS_V4 rejected as an authentication typeName (localhost:root): mytest331 Please specify the password.Password:500 OOPS: cannot change directory:/home/mytestLogin failed.這裡是解方法:首先,檢查一下mytest檔案夾的許可權[root@localhost home]# ls -l mytestdrwxr-xr-x 2 root root 4096 08-10 15:32 mytest發現許可權沒設好,這裡我使用drwxrwxrwx許可權[root@localhost home]# chmod 777 mytest設定好許可權後重啟vsftpd [root@localhost home]# service vsftpd restart登陸後可能還會出現以上問題,這時可能是SELinux的問題,以下是解決方案: [root@localhost home]# setsebool -P ftpd_disable_trans 1這個是關於SELinux的設定,不瞭解,可能是讓vsftpd通過SELinux,關於P選項的意思是長久生效,如果不加P選項的話,重啟後可能還要使用命令setsebool -P ftpd_disable_trans 1來解決以上的問題。至此,新使用者就建立完成並能夠登陸使用了。[root@localhost home]# ftp localhostConnected to localhost.localdomain.220 (vsFTPd 2.0.5)530 Please login with USER and PASS.530 Please login with USER and PASS.KERBEROS_V4 rejected as an authentication typeName (localhost:root): mytest331 Please specify the password.Password:230 Login successful.Remote system type is UNIX.Using binary mode to transfer files.ftp>