VSFTP with virtual users
In this tutorial we will learn how to install vsftp with virtual user support. We will assume that you HAVE already installed the vsftp application. As we do want a separate ftp server, our configuration is parallel to the standard vsftp config.
First go to
cd /etc/vsftpdThe enter the following lines in the file myserver.conf
vi myserver.confpam_service_name=myserveranonymous_enable=NO
local_enable=YES
write_enable=YES
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
chroot_local_user=YES
guest_enable=YES
guest_username=apache
listen=YES
listen_port=5909
pasv_min_port=30000
pasv_max_port=30999
xferlog_file=/var/log/myserver.log
xferlog_std_format=YES
In this case all the files uploaded by our virtual users will be set to apache. The server is running on port 5909 and everything will be logged on var/log/myserver.log . You will have to pay attention to the home directory of the user specified in guest_username setting it to a proper directory where the user will operate.
Then we do
vi /etc/pam.d/myserverand we enter the following lines
#%PAM-1.0auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/myserveruser
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/myserveruser
Also in this case you have to pay attention to the pam_userdb location... Our is under lib64!
Then we create a user file map under /etc/vsftpd/
vi myserveruser_map.txtIn this file we enter each virtual user we want. The syntax is quite simple as the username and the password are put in different lines. The following will define a foo user with a bar password
foobar
To compile the file you must type
db41_load -T -t hash -f myserveruser_map.txt /etc/vsftpd/myserveruser.dbThen we will restart the vsftpd service:/etc/init.d/vsftpd restart
/etc/init.d/vsftpd restartNow you can try the installation by typing
ftp localhost 5909and login with the user foo and password bar. If everything is ok... you will see the "login successfull" message.
If something goes wrong:
touch /etc/pam_debugvi /etc/syslog.conf
At the bottom of the file enter:
*.debug***TAB***Then restart syslog
/etc/init.d/syslog restartThen you can watch into the file /tmp/debugpam.log to look for error messages (yes... you have to try the ftp server!)
Once everything is ok just remove /etc/pam_debug and the inserted line in /etc/syslog.conf and restart syslog.