Ubuntu 17.04: Install vsftpd for FTP server


Table of Contents

1 Install vsftpd

Install vsftpd package.

$ sudo apt install -y vsftpd

Enable upload by local user. Enable read by anonymous user. Disable upload by anonymous user.

$ cat <<EOF | sudo tee /etc/vsftpd.conflisten=YESlocal_enable=YESxferlog_enable=YESconnect_from_port_20=YESpam_service_name=vsftpd# Enable upload by local user.write_enable=YES# Enable read by anonymous user (without username and password).secure_chroot_dir=/var/run/vsftpd/emptyanonymous_enable=YESanon_root=/srv/ftpallow_anon_ssl=YESno_anon_password=YESEOF

Create directory for anon_chroot.

$ sudo mkdir /srv/ftp$ sudo chown nobody:nogroup /srv/ftp$ echo “anon” | sudo tee /srv/ftp/anon.txt

Enable and restart vsftpd.

$ sudo systemctl enable vsftpd$ sudo systemctl restart vsftpd

2 Access to vsftpd

Access to vsftpd with lftp.

$ sudo apt install -y lftp

Access to vsftpd with specifying user. You can specify password with -u <username>,<password>. Home directory is displayed. You can access directory and files of FTP server with using user permission.

$ lftp -u hiroom2 ftp-server.hiroom2.comPassword:lftp [email protected]:~> pwdftp://[email protected]/%2Fhome/hiroom2lftp [email protected]:~> ls /drwxr-xr-x 2 0 0 4096 Jul 29 07:12 bindrwxr-xr-x 4 0 0 1024 Aug 05 12:16 bootdrwxrwxr-x 2 0 0 4096 Oct 09 2016 cdrom-rw——- 1 0 0 17711104 Jan 21 2017 coredrwxr-xr-x 21 0 0 4020 Aug 06 01:22 devdrwxr-xr-x 133 0 0 12288 Aug 06 01:22 etcdrwxr-xr-x 4 0 0 4096 Aug 06 01:22 home<snip>

Not specifying user uses anonymous user. The directory which is set to anon_root is displayed. Anonymous user cannot access upper directory because vsftpd uses chroot.

$ lftp ftp-server.hiroom2.comlftp ftp-server.hiroom2.com:~> pwdftp://ftp-server.hiroom2.comlftp ftp-server.hiroom2.com:~> ls /-rw-r–r– 1 0 0 5 Aug 06 01:22 anon.txt

Android | Linux | SDL - Narrow Escape