12/14/2009

Setup Virtual Users in vsftpd

為什麼是Virtual Users? 基本上就是不想在系統中開帳號,針對ftp需要開啟所需要帳號既可。

為什麼選擇vsftpd,快又安全同時又支援virtual Users特性(似乎ftpd都有了!)

Despite being small for purposes of speed and security, many more complicated FTP setups are achievable with vsftpd

Ubuntu環境中先安裝下例套件,其中當然有很多PAM 認證方式,我選擇最容易方法使用libpam-pwdfile apt-get install vsftpd apt-get install libpam-pwdfile

新增virtual user touch /etc/vsftpd/passwd htpasswd -c /etc/vsftpd/passwd partner1 htpasswd /etc/vsftpd/passwd partner2

修改vsftpd認證方式,將/etc/pam.d/vsftpd全部注解(除非還要使用不同的PAM認證),加入pam_pwdfile認證方式 sudo vim /etc/pam.d/vsftpd auth required pam_pwdfile.so pwdfile /etc/vsftpd/passwd debug account required pam_permit.so debug

微調/etc/vsftpd.conf,關掉不必要anonymous 登入 listen=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES #chroot 所指定的目錄 chroot_local_user=YES secure_chroot_dir=/var/run/vsftpd pam_service_name=vsftpd rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key user_config_dir=/etc/vsftpd/user #比較重要設定將guest_enable開啟,否則會出現500 OOPS: cannot locate user entry:partner1錯誤 guest_enable=YES guest_username=ftp guest_username=ftp, vsftpd需要一個system account去替代virtual users,否則會找不到目錄( cannot locate user entry),剛好ftp account是安裝時預設建立直接使用預設就可以。

針對partner1與partner2 分別去調整權限 vim /etc/vsftpd/user/partner1 vim /etc/vsftpd/user/partner2 根據不同的需求調整內容如下: write_enable=YES anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES local_root=/home/partner

測試ftp localhost

Connected to localhost.
220 (vsFTPd 2.0.7)
Name (localhost:chliu): partner1
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

No comments:

Post a Comment