Installing vsftpd on Ubuntu 12.04

From Zam Wiki
Jump to: navigation, search

1. Make sure your OS is updated

apt-get update
apt-get upgrade

2. Install vsftpd

apt-get install vsftpd

3. Edit the vsftpd config file

vi /etc/vsftpd.conf

Copy this line below:

# Example config file /etc/vsftpd.conf
#
listen=YES
anonymous_enable=NO     # Allow anonymous FTP?
local_enable=YES        # Allow local users to log in
write_enable=YES        # Enable any form of FTP write command
dirmessage_enable=YES   # Activate directory messages
use_localtime=YES
xferlog_enable=YES      # Activate logging of uploads/downloads
connect_from_port_20=YES

secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem

local_root=/usr/share/nginx/www/     # Specifies the directory vsftpd changes to after a user logs in
userlist_enable=YES                  # If user tries to log in using a name in this file, they will be denied before they are asked for a password
userlist_file=/etc/user_list         # Path to userlist_file

You can change local_root dir to your preferred that you want.


4. Edit ftpusers file

vi /etc/ftpusers

Put comment/hash in front of word root e.g. #root


5. Create new file for user_list but do not fill anything

touch /etc/user_list

6. Restart the vsftpd

service vsftpd restart

Making vsftpd with chrooted users work again on Ubuntu 12.04

If you get erro something like this:

500 OOPS: vsftpd: refusing to run with writable root inside chroot ()

You need to put this code into vsftpd.conf

allow_writeable_chroot=YES

But unfortunately, the latest vsftpd doesn't support this feature. :(

So, with help from The Frontier Group, they have backported previous vsftpd to Ubuntu 12.04. To use it, run this command:

sudo add-apt-repository ppa:thefrontiergroup/vsftpd
sudo apt-get update
sudo apt-get install vsftpd

Then put this code to your vsftpd.conf

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
allow_writeable_chroot=YES <-- add this line
blog comments powered by Disqus