Øystein Kjærnet Archive Pages Categories Tags

Setting up an FTP server

01 July 2013

Install vsftpd: sudo apt-get install vsftpd

Add a safe ftp-user (seems to need an actual shell, even though most tutorials recommend setting -s /bin/false:

sudo useradd ftpuser -d /home/ftpuser -s /bin/bash
sudo passwd ftpuser

Create download and upload-directories, as, because of some security issue, the root shared directory shouldn’t be writable.

sudo mkdir /home/ftpuser
cd /home/ftpuser
sudo mkdir download upload
sudo chown -R ftpuser:ftpuser .
sudo chmod 550 download
sudo chmod 550 .

Configure /etc/vsftpd.conf to allow only ftpuser to log in and jail (chroot) him in pub directory.

anonymous_enable=NO
local_enable=YES
write_enable=YES
userlist_deny=NO
userlist_enable=YES
userlist_file=/etc/vsftpd.allowed_users
chroot_local_user=YES
chroot_list_enable=NO

Then add the line ftpuser to /etc/vsftpd.allowed_users and restart vsftpd: sudo service vsftpd restart.

The port will be 21 (even though one line says connect_from_port_20=YES). Download folder will be accessible as /download and upload as /upload.

Sources:


blog comments powered by Disqus
Fork me on GitHub