- # ftp 127.0.0.1
- Connected to 127.0.0.1 (127.0.0.1).
- 220 Welcom to my FTP server.
- Name (127.0.0.1:root): gou
- 331 Please specify the password.
- Password:
- 230 Login successful. Have fun.
- Remote system type is UNIX.
- Using binary mode to transfer files.
測試下載服務器目錄中的一個文件mytest:
- ftp> get mytest
- local: mytest remote: mytest
- 227 Entering Passive Mode (127,0,0,1,159,19)
- 150 Opening BINARY mode data connection for mytest (21 bytes).
- 226 File send OK.
- 21 bytes received in 0.00038 secs (54 Kbytes/sec)
測試上傳本機目錄中的文件vsftpd.conf:
- ftp> !ls
- account.db chroot_list k mytest userconf vsftpd.conf
- ftp> put vsftpd.conf
- local: vsftpd.conf remote: vsftpd.conf
- 227 Entering Passive Mode (127,0,0,1,117,203)
- 150 Ok to send data.
- 226 File receive OK.
- 4229 bytes sent in 0.00195 secs (2.1e+03 Kbytes/sec)
可以看到,使用沒有系統賬號的虛擬用戶可以成功完成上傳、下載的工作。但該FTP虛擬服務器只允許虛擬用戶登錄,其它系統用戶無法登錄,如系統用戶user1不是虛擬用戶,則不能登錄該虛擬服務器。
- # ftp 127.0.0.1
- Connected to 127.0.0.1 (127.0.0.1).
- 220 Welcom to my FTP server.
- Name (127.0.0.1:root): user1
- 331 Please specify the password.
- Password:
- 530 Login incorrect.
- Login failed.
在虛擬FTP服務器中,也可以對各個用戶的權限進行設置。方法是在/etc/vsftpd.conf文件中添加如下一行:
- user_config_dir=用戶配置文件目錄
然后在用戶配置文件目錄下創建相應的用戶配置文件,比如為上述名為gou的用戶創建一個配置文件(假設配置文件目錄為/etc/user_config_dir):
- #vi /etc/user_config_dir/gou
- write_enable=NO
- anono_upload_enable=NO
重啟FTP服務器,這時再使用賬號gou來登錄,就已經沒有上傳的權限了。