所謂虛擬,就是說這個使用者不是系統使用者,而只是ProFTPD自己的私人使用者。和windows中的FTP server軟體serv-U中的使用者很像。由於不是系統使用者,使用虛擬使用者可以提高安全性。
虛擬使用者的資訊可以從普通檔案、資料庫、LDAP伺服器等地方獲得。此處介紹最簡單的一種,讓ProFTPD從檔案獲得虛擬使用者資訊。
1. 在/etc/proftpd.conf中加入
RequireValidShell off
AuthOrder mod_auth_file.c
AuthUserFile /usr/local/etc/proftpd/passwd
AuthGroupFile /usr/local/etc/proftpd/group
其中,AuthOrder指定了許可權檢查的順序。這裡只使用虛擬使用者。AuthUserFile和AuthGroupFile的檔案格式看passwd(5)和group(5)。如果使用者名稱和組名與系統的重複,看DirFakeUser和DirFakeGroup。
2. 使用ftpasswd建立passwd和group檔案
$ ftpasswd --passwd --file=/usr/local/etc/proftpd/passwd --name=test1 --uid=2001 \
--home=/home/nohome --shell=/bin/false
$ ftpasswd --passwd --file=/usr/local/etc/proftpd/passwd --name=test2 --uid=2002 \
--home=/home/nohome --shell=/bin/false
建立了一個test1和test2使用者
$ ftpasswd --group --name=test --gid=2001
建立了一個test組
$ ftpasswd --group --name=test --gid=2001 --member=test1 --member=test2
把test1和test2加入test組
3. 重啟proftpd
備忘:
ftpasswd命令在proftpd的原始碼包裡就有,比如我的就在:
/usr/src/proftpd-1.3.1/contrib/ftpasswd
把ftpasswd改為可執行,拷貝到你可以用的任意地方就行了。
參考:
http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-Authentication.html
http://www.castaglia.org/proftpd/contrib/ftpasswd.html
http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-AuthFiles.html
http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-VirtualUsers.html