Installing a basic FTP server into Ubuntu 18.04 Bionic Beaver using vsftpd is a straightforward process. In this article we will cover installing the basic packages needed, setting up a user, setting up encryption, and then test connecting to it.
Install vsftpd
- Enter the Following Command to Install vsftpd
sudo apt-get install vsftpd -y
- Start the vsftpd Service and Set It to Start on Boot
sudo systemctl start vsftpd sudo systemctl enable vsftpd
Setup Directory Structure For FTP
- Create a User
sudo adduser testuser1
- Create a Directory and Set Ownership
sudo mkdir /home/testuser1/ftp sudo chown nobody:nogroup /home/testuser1/ftp sudo chmod a-w /home/testuser1/ftp
- Create a Directory Where Files Can Be Uploaded and Give Ownership to the Test User
sudo mkdir /home/testuser1/ftp/test sudo chown testuser1:testuser1 /home/testuser1/ftp/test
Configure vsftpd
- Backup vsftpd’s Original Config File
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
- Open and Edit the vsftpd.conf File
sudo nano /etc/vsftpd.conf
- Add the Following to the File
listen=NO listen_ipv6=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES use_localtime=YES xferlog_enable=YES connect_from_port_20=YES chroot_local_user=YES secure_chroot_dir=/var/run/vsftpd/empty pam_service_name=vsftpd pasv_enable=Yes pasv_min_port=10000 pasv_max_port=11000 user_sub_token=$USER local_root=/home/$USER/ftp userlist_enable=YES userlist_file=/etc/vsftpduserlist.conf userlist_deny=NO
- Save and Close the Config Filevsftpd has many configuration options so you may need to make further adjustments based on your local server setup.
- Add The testuser1 User We Created to vsftpd’s User List File
sudo nano /etc/vsftpduserlist.conf
- Restart the vsftpd Service to Apply These Changes
sudo systemctl restart vsftpd
Setup Security with SSL/TLS
- >Create a Security Certificate
sudo mkdir /etc/certs sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/certs/vsftpd.pem -out /etc/certs/vsftpd.pem
- Open the vsftpd.conf File
sudo nano /etc/vsftpd.conf
- Add the Following Lines to the File
rsa_cert_file=/etc/certs/vsftpd.pem rsa_private_key_file=/etc/certs/vsftpd.pem ssl_enable=YES allow_anon_ssl=NO force_local_data_ssl=YES force_local_logins_ssl=YES ssl_tlsv1=YES ssl_sslv2=NO ssl_sslv3=NO require_ssl_reuse=NO ssl_ciphers=HIGH
- Save the File and Restart vsftpd
sudo systemctl restart vsftpd
To test, configure your favorite FTP client to connect to your server and make sure to set the encryption settings when you login.
You should see the FTP server contents upon login.
Check out the top 3 Best web hosting services
Hostinger
IONOS
Ultahost
- Your query to the best web hosting can end by clicking on this link.