Ubuntu 16.04 FTP server installation + configuration

Keywords: ftp vsftpd sudo SSL

ftp server installation and configuration

1. Installation of FTP server

If the server configured before or after ftp server fails to start the service, the basic problem is that there is an error in the configuration. You can uninstall it completely before installing it. If you cannot locate the image source, replace the alisource.

sudo apt-get update 
sudo apt-get install vsftpd
vsftpd --version     //Check if it is installed
2. Configuration of FTP server
 vim /etc/vsftpd.conf    //Edit profile

Modify the vsftpd.conf file as follows:

listen=NO                 //Enable monitoring of ipv4 and ipv6 data      
listen_ipv6=YES          //Enable monitoring ipv6 data

# Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO      //Allow anonymous login without password

# Uncomment this to allow local users to log in.
local_enable=YES        //Allow local users to log in

# Uncomment this to enable any form of FTP write command.
write_enable=YES        //Allow login to upload files

# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022         //Set the default permissions for local users to be exempted

# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES       //Directory message, which can send directory to remote login users
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES           //The directory displayed by the server will change over local time
#
# Activate logging of uploads/downloads.
xferlog_enable=YES          //Enable log recording of upload and download
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES    //Confirm that the port number of the connection transmission is 20

# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log    //Log file storage location
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES          //Log files in standard format


# You may fully customise the login banner string:
ftpd_banner=Welcome to FTP service.  //Logging in when using shell will send a welcome message


# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES        //Whether to impose restrictions on local users
chroot_list_enable=YES       //Open restricted white list
# (default follows)         
chroot_list_file=/etc/vsftpd.chroot_list        //Whitelist path. If you don't have this file, you need to create it yourself

# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
# pam_service_name=vsftpd
pam_service_name=ftp            //Here, the system of ubuntu needs to be changed to ftp

# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO                 

#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
utf8_filesystem=YES       //The code is unified as utf8 code, which can identify Chinese and prevent garbled code
 3. vftpd configuration completed

Add settings ftpuser user and access directory

 1. Create ftp user groups and users
sudo groupadd ftpusers //Create ftpusers user group
sudo useradd -m ftpuser_lxr//Create a user and automatically create the home directory as / home / ftpuser [LXR
(The second way: mkdir /home/ftpuser_lxr //Create the home directory sudo userad - D / home / ftpuser? LXR ftpuser? LXR / / bind this home directory)
usermod -G ftpusers ftpuser_lxr //Add this new user to the ftpusers user group
sudo passwd ftpuser_lxr   //Change password
mkdir /home/ftpuser_lxr/ftp  //Add a folder with certain permissions for users
chmod 777 -R /home/ftpuser_lxr/ftp //Create a new pub directory to store files and give all permissions
usermod -s /sbin/nologin username  //Restrict user login mode; restrict user username to log in through ftp, not directly to the server
2. Add the user to the white list of vsftpd.chroot list
mkdir /etc/vsftpd.chroot_list
vim vsftpd.chroot_list

The contents of the document are as follows:

#White list
ftpuser_lxr
3. Start and restart vsftpd service

systemctl start vsftpd or service vsftpd start
systemctl restart vsftpd or service vsftpd restart

test

Method 1:

Open the browser, and enter FTP: / / IP "addresses in the address bar

Method two:

 Using shell input in ubuntu: FTP IP "address

Method three:

 In windows, enter FTP: / / IP "addresses in the file manager address field, which can upload and download files

Method four:

 Use cmd in windows to input: FTP: / / ip_addresses / / the connection is successful

Posted by nebb on Sat, 04 Jan 2020 09:56:14 -0800