昨天開始就一直在弄vsftp, 只需要測試一下板子的dn和up速度.不需要太多的安全性考慮,兩個問題.匿名和root使用者登入,上傳檔案,在網上找到的東西感覺都很亂而且試了全都失敗..最後終於看到一篇能讓人看明白且好使的..轉過來放著..
vsftpd 基本配置實踐 匿名anonymous使用者上傳檔案 和 root 登陸
可可火山 20080411
http://linux.chinaunix.net/bbs/viewthread.php?tid=989486&extra=&page=1
以下為在CentOS中測試,讓匿名anonymous使用者上傳檔案,一切設定檔從初時狀態開始:
1.file:/etc/vsftpd/vsftpd.conf
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES
2.anonymous登陸後發現還是不能upload,報許可權錯誤,不管在/目錄還是/pub.檢查/pub許可權發現許可權很低.
[root@CentOS5 pub]# ls -ld /var/ftp/pub/
drwxr-xr-x 3 root root 4096 Mar 17 00:07 /var/ftp/pub/
這個時候需要建個目錄來讓使用者上傳.
[root@CentOS5 pub]# mkdir /var/ftp/incomming
[root@CentOS5 pub]# chmod a+w /var/ftp/incomming
3.重新匿名使用者登陸,在/incomming內上傳檔案和建目錄OK.
以下為在CentOS中測試,讓root通過ftp登陸,一切設定檔從初時狀態開始:
1.刪除/etc/vsftpd/user_list中的root一行.
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
這樣用root登陸,不會直接deny,但輸入正確密碼還是不能登陸.查看/etc/log/secure就可以發現pam阻止了root的登陸.
2.找到/etc/pam.d/vsftpd發現pam會檢查/etc/vsftpd/ftpusers設定檔.
開啟/etc/vsftpd/ftpusers的第一行說明了這個設定檔的作用
# Users that are not allowed to login via ftp
刪除root一行重啟vsftpd後root就可以登陸了.
後話:1.ftp屬於明文傳輸,有安全隱患.更不用說拿root直接登陸ftp.
2.推薦使用ssh,即可以跑命令也可以傳檔案.