Implementation code for installing vsftpd in Ubuntu 18.04

Implementation code for installing vsftpd in Ubuntu 18.04

Install vsftpd

$ sudo apt-get install vsftpd -y

Start the vsftpd service and set it to start at boot

$ sudo systemctl start vsftpd
$ sudo systemctl enable vsftpd

Set up the FTP directory structure

Create a User

$ sudo adduser testuser1

Create the directory and set ownership

$ sudo mkdir /home/testuser1/ftp
$ sudo chown nobody:nogroup /home/testuser1/ftp
$ sudo chmod aw /home/testuser1/ftp

Create a directory where you can upload files and set ownership for

$ sudo mkdir /home/testuser1/ftp/test
$ sudo chown testuser1:testuser1 /home/testuser1/ftp/test

Configure vsftpd

Back up the original configuration file of vsftpd

$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

Open and edit the vsftpd.conf file

$ sudo vi /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

4. Save and close the configuration file

:wq

5. Add the testuser1 user we created to the vsftpd user list file

$ sudo vi /etc/vsftpduserlist.conf

6. Restart the vsftpd service to apply these changes

$ sudo systemctl restart vsftpd

Using SSL/TLS

Creating 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 vi /etc/vsftpd.conf

Add the following 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

Use SFTP protocol to log in to the added user in the FTP client

Configuring the Firewall

$ sudo ufw allow OpenSSH
$ sudo ufw allow 20/tcp
$ sudo ufw allow 21/tcp
$ sudo ufw allow 40000:50000/tcp
$ sudo ufw allow 990/tcp

$ sudo ufw enable
$ sudo ufw status

References: DevAnswers.co, hostadvice.com

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Install and configure FTP server in Ubuntu
  • Detailed steps to install vsftpd FTP on Ubuntu
  • Implementation steps for installing FTP server in Ubuntu 14.04

<<:  In-depth explanation of the impact of NULL on indexes in MySQL

>>:  Examples and comparison of 3 methods for deduplication of JS object arrays

Recommend

idea uses docker plug-in to achieve one-click automated deployment

Table of contents environment: 1. Docker enables ...

Summary of JavaScript custom object methods

Table of contents 1. Use object to create an obje...

About dynamically adding routes based on user permissions in Vue

Display different menu pages according to the use...

Summary of methods for finding and deleting duplicate data in MySQL tables

Sometimes we save a lot of duplicate data in the ...

MySQL service and database management

Table of contents 1. Start and stop service instr...

Detailed explanation of Mybatis special character processing

Preface: Mybatis special character processing, pr...

N ways to achieve two-column layout with CSS

1. What is a two-column layout? There are two typ...

MySQL slow query log configuration and usage tutorial

Preface MySQL slow query log is a function that w...

8 essential JavaScript code snippets for your project

Table of contents 1. Get the file extension 2. Co...

CSS scroll bar style modification code

CSS scroll bar style modification code .scroll::-...

Details on how to write react in a vue project

We can create jsx/tsx files directly The project ...

MySQL merge and split by specified characters example tutorial

Preface Merging or splitting by specified charact...

More popular and creative dark background web design examples

Dark background style page design is very popular...