Ubuntu 16.04 LTS – How to Install and Configure vsFTPd on Ubuntu

FTP is used to transfer files from one host to another over TCP network. This article explains how to setup FTP server on ubuntu 16.04. There are 3 popular FTP server packages available PureFTPd, VsFTPD and ProFTPd. Here i’ve used VsFTPD which is most secure. I’ll be logged in as root.

Setup vsFTPd server on Ubuntu 16.04


Step 1 – Update repositories.

root@mail:/# apt-get update
root@mail:/# apt-get upgrade

Step 2 – Install VsFTPD

root@mail:/# apt-get install vsftpd

Step 3 – Backup config file

root@mail:/# cp /etc/vsftpd.conf /etc/vsftpd.conf.backup

Step 4 – Open config file with follow command.

root@mail:/# nano /etc/vsftpd.conf

Step 5 – Configration of vsFTPd file – Open /etc/vsftpd.conf file and search with Ctrl+W and make changes as it is shown below. Remove commends if they exist or add missing line.

anonymous_enable=NO
local_enable=YES
write_enable=YES
allow_writeable_chroot=YES
chroot_local_user=YES
file_open_mode=0777
local_umask=022

Step 6 – Configration of vsFTPd file – Allow access only for certain users.

userlist_deny=NO
userlist_enable=YES
userlist_file=/etc/vsftpd.allowed_users

Step 7 – Create /etc/vsftpd.allowed_users

touch /etc/vsftpd.allowed_users

Step 8 – Include users who should have access in /etc/vsftpd.allowed_users

m.slavov
yourSECONDuser
yourTHIRDuser

Step 9 – If you want, you can make Advanced Configuration

#Useful to not write over hidden files:
force_dot_files=YES

#Hide the info about the owner (user and group) of the files.
hide_ids=YES

#Maximum number of clients:
max_clients=20

#Connection limit for each IP:
max_per_ip=2

#Chnage listen port from 21 to other
listen_port=999

Step 10 – Add ftp user and change home directory for this user. This is very important because you will restrict the user to access to one directory. You can allow access to /var/www/ and the user will have access to all folders on your sites or choose to access to only one site. For example if you want to create ftp user and to allow him to access to only one site, write the following commands. And don’t forget to add new user in /etc/vsftpd.allowed_users

root@mail:/# adduser ftp
root@mail:/# usermod –home /var/www/YOURFOLDERSITE ftp

or open this file /etc/passwd and search user which you want to change home directory. Change /home/ftpuser with /vat/www.

root@mail:/# nano /etc/passwd
root@mail:/# ftpuser:x:1001:1001:FTP USER,,,:/var/www:/bin/bash

Step 11 – Restart vsFTPd – You must restart vsFTPd service for the changes to take effect. Now when user connect via ftp with filezilla he will see only one folder from your sites.

root@mail:/# systemctl restart vsftpd

If you want to see output from command you ca execute this command /etc/init.d/vsftpd restart

Step 12 – Show vsftpd status with systemctl status vsftpd

Step 13 – Configuration of permissions – If you want everybody to have a permission to write in this folder, you have to set full permission 777. If you want only the ftp group to have permission to write and everyone else to have permission only to read, you have to set a permission 775.

root@mail:/# chmod 777 -R /var/www/YOURFOLDERSITE
root@mail:/# chown ftp:ftp -R /var/www/YOURFOLDERSITE

6 ThemeHow to install and configure SSH on Ubuntu (Server) 14.04 LTS Step-by-Step

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*
Website