Installing vsftpd using text file for virtual users
vsftpd is a secure, fast and stable FTP server. In this tutorial we'll install the server and make it check in a flat text file for virtual users allowed to login.
1. Install required packages
sudo apt-get install vsftpd libpam-pwdfile
2. Configure vsftpd (sudo pico /etc/vsftpd.conf)
Edit these variables in the config file and leave everything else with the default value.
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES
virtual_use_local_privs=YES
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/$USER
hide_ids=YES
Set the local_root to the parent directory where the user's home directories are located
3. Configure PAM to check the passwd file for users (sudo pico /etc/pam.d/vsftpd)
auth required pam_pwdfile.so pwdfile /etc/ftpd.passwd
account required pam_permit.so
Make sure you remove everything else from the file
4. Create the passwd file containing the users
sudo htpasswd -c /etc/ftpd.passwd user1
You can later add additional users to the file like this:
sudo htpasswd /etc/ftpd.passwd user2
5. Restart vsftpd
sudo /etc/init.d/vsftpd restart
6. Create user's home directory since vsftpd doesn't do it automatically
sudo mkdir /var/www/user1
November 12th, 2009 - 02:33
This was just what I was looking for. Thank You for posting this!
January 8th, 2010 - 13:15
Thank You for this tutorial!
March 30th, 2010 - 17:44
Hi,
I just did this tutorial but i came up with a 530 Login incorrect. error!
Help?
March 31st, 2010 - 00:03
@Gangsterkb: Can you check if you see any related messages in /var/log/auth.log or /var/log/vsftpd.log?
April 29th, 2010 - 21:27
Hey thanks, I was searching for this!! Precise and clear. I might translate it and put it on my site. Tested procedure under Ubuntu 9.10 Karmic Koala.
May 18th, 2010 - 12:40
Isn’t this the same as creating an user with the Ubuntu standard PAM system?
May 18th, 2010 - 12:50
or this is to make it more secure? using a PAM system that is independent from normal users?
what about virtual folders?
May 19th, 2010 - 08:14
i’m getting a “553 Could not create file” error in Ubuntu 10.04
June 2nd, 2010 - 01:55
in Ubuntu 10.04 : 550 Create directory operation failed.
June 22nd, 2010 - 15:40
The above tutorial doesn’t work for me in Ubuntu 10.04. I created the user ‘quad’ using the above method, but when I try to login, I get this error:
ftp> open localhost
Connected to localhost.
220 (vsFTPd 2.2.2)
Name (localhost:serrano): quad
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
I am able to login with my user account though.
June 22nd, 2010 - 15:52
Forget my last comment. It seems that sometimes “sudo /etc/init.d/vsftpd restart” doesn’t immediately load the new settings. After I rebooted, everything worked fine