環境:本地ubuntu系統&服務器ubuntu系統
本地安裝filezilla
apt-get install filezilla '安裝filezilla
filezilla ‘運行
服務器安裝vsftp 參照 阿里雲安裝vsftp
apt-get install vsftpd -y ’安裝vsftp
添加ftp帳號和目錄
先檢查一下nologin的位置,通常在/usr/sbin/nologin或者/sbin/nologin下。
使用下面的命令創建帳戶,該命令指定了/alidata/www/wwwroot爲用戶pwftp的家目錄,您可以自己定義帳戶名和目錄
useradd -d /alidata/www/wwwroot -s /sbin/nologin test ‘添加ftp帳號,加粗爲虛擬目錄,假設賬戶爲test
修改該帳戶密碼:
passwd pwftp ’創建密碼
123456 ’假設爲密碼
將配置文件中”anonymous_enable=YES “改爲 “anonymous_enable=NO”
取消如下配置前的註釋符號:
local_enable=YES
write_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
保存退出
編輯/etc/vsftpd.chroot_list文件,將ftp的帳戶名添加進去,保存退出
vi /etc/vsftpd.chroot_list '此文件默認是沒有的,新創建的
test 123456 '直接將賬戶和密碼放入
修改shell配置,vi編輯/etc/shells,如果該文件裏沒有/usr/sbin/nologin或者/sbin/nologin(具體看當前系統配置)則追加進去
vi /etc/shells
/usr/sbin/nologin ‘直接添加進去
重啓vsftp服務並測試登錄
service vsftpd restart
本地用filezilla登錄ftp,報錯
500 OOPS: could not read chroot() list file:/etc/vsftpd.chroot_list
Error: Critical error
Error: Could not connect to server</span>
解決:
chmod a-w /alidata/www/wwwroot ‘去除根目錄的寫權限
重新登錄,登錄成功,可看到文件。