Windows.  Viruses.  Notebooks.  Internet.  office.  Utilities.  Drivers

Just recently I was writing about that on my computer. This is very useful for a webmaster, since by installing such a "home" server, you can conduct various experiments with test sites or simply develop them.

But there is one problem: if you, for example, try on such local server install the same plugin in wordpress, you will get rejected: " Failed to connect to FTP server localhost:21"

As you understand, you need to install and configure an ftp server on your computer in order to install plugins. How to install ftp server to your Linux machine?

There are many free servers on Linux, I tried several and settled on vsftpd. This server is lightweight and easy to set up.

1. How to install vsftpd ftp server?

You can install it with one command:

sudo apt-get install vsftpd

After installing the server, we need to configure it a bit. But first, let's test our ftp server, enter the following address into the browser: ftp://127.0.0.1/ We should see the following:


But it is not enough to install the vsftpd server, as you can see it is done simply, it is important to set up the ftp server. But this is also done simply, if you follow my experience.

2. How to setup vsftpd ftp server?

To get to the server settings, enter the command in the terminal:

sudo gedit /etc/vsftpd.conf

Delete everything from this file and paste this:

Listen=YES # make anonymous access, writable anonymous_enable=YES no_anon_password=YES anon_root=/ PATH TO THE FOLDER WITH THE SITE! anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES anon_umask=022 # allow local users with write access to home directories local_enable=YES local_umask=022 write_enable=YES # put local users in their home directories, otherwise the user will have access to the system root. chroot_local_user=YES chroot_list_enable=YES # logging settings xferlog_enable=YES vsftpd_log_file=/var/log/vsftpd.log

Restart the ftp server with the command:

sudo /etc/init.d/vsftpd restart

Yes, it's very important! You need to give access to the folder with the site and all files to it 755, public write rights to the folder DO NOT!

You can install a new, more correct version of the server by adding:

sudo add-apt-repository ppa:thefrontiergroup/vsftpd sudo apt-get update sudo apt-get install vsftpd

After that, we go to the WordPress admin panel and try to install some plugin. We will be asked to enter the server address, username and password. In the server line we write 127.0.0.1 , and write the login and password - anonymous

If you get an error: Could not determine the WordPress content directory (wp-content), then you need to insert the following code at the end of the wp-config.php file:

If (is_admin()) ( add_filter ("filesystem_method", create_function("$a", "return "direct";")); define ("FS_CHMOD_DIR", 0751); )

After that, everything worked for me. So setting up the vsftpd server is over for me. This is how you can install and configure ftp server vsftpd on your home computer.

Such a server, of course, will not be too productive, this is not a real IBM HS23e server on SSD drives. And if you give access to it with all your local network, your computer can sweat a lot, constantly copying something.

But my goal is clear to you, but it is certainly not the only one. FTP server on your computer can be used for different purposes, and most often these simple settings suit you. If not, there are many manuals on the net for setting up this FTP server. Good luck!

I add: as it turned out, in my case, you can do without FTP at all. It is easier to work through SSH and the ssh-sftp-updater-support plugin, which adds the SSH protocol to WordPress. It's much safer this way and you don't need to set up an FTP server.


Did not find an answer to your question? Use search...

In this tutorial, we will show you how to install and configure VSFTPD on . VSFTPD is an acronym for Daemon's Very Secure File Transfer Protocol. It's free and open source code, fast, stable, lightweight and very secure FTP server for operating systems Unix and Linux installed under the GNU General Public License. VSFTPD is one of the most used FTP servers for Linux and is used as the default FTP server in some of the biggest distributions such as Fedora, Ubuntu, NimbleX, Slackware and RHEL.

In order to install VSFTPD on your Ubuntu 16.04 server, you must SSH in as root

ssh root@IP_address

First of all, make sure everything installed packages are up to date

apt-get update && apt-get upgrade

All you have to do to install VSFTPD on your Ubuntu 16.04 VPS is to run the following command in your Linux terminal

apt-get -y install vsftpd

After it is successfully installed, we need to make some changes to its configuration. Open file /etc/vsftpd.conf find and change the following lines:

Vim /etc/vsftpd.conf # Control anonymous login, allowed or not. anonymous_enable=NO # Local users to login local_enable=YES # Set "write_enable", in order to allow changes to the filesystem write_enable=YES # Enable sending to ASCII (to prevent loading scripts, etc. from being hacked), # no risk Main size and download in ASCII format. ASCII must be # on the client anyway. ascii_upload_enable=YES ascii_download_enable=YES # You can set the root directory for FTP users. If not specified, the user's home directory is equal to the FTP root local_root=public_html

Save the configuration file and restart the FTP server for the changes to take effect

systemctl restart vsftpd

Set VSFTPD to start automatically on system boot

Systemctl enable vsftpd

You can find a list of all options in the config file at http://vsftpd.beasts.org/vsftpd_conf.html

Root logins are disabled by default in VSFTPD for security reasons. In order to access your FTP server, you will have to create a new system user

Adduser FTPUSER

Where FTPUSER is the username you want to create. You will be prompted to enter a new password for the new user and a few additional details such as full username, phone number, etc. Please note that it is very important to always use for accounts. It is best to use a combination of letters and numbers and at least 10 characters.

Now, once your FTP server is both installed and configured, and a new FTP user is created, you can access the FTP server with the newly created user using a terminal, web browser, or using an FTP client such as FileZilla.

FTP (File Transfer Protocol) is a file transfer protocol. The FTP protocol allows you to transfer and download files from a server. To date, this protocol is not particularly popular, since it does not support data encryption. Instead of FTP, they use the SFTP protocol (data transfer over SSH), as well as the SCP protocol. This article covers how to set up a regular FTP server on Ubuntu base.

The FTP protocol works in client-server mode. The server constantly listens for requests from remote clients on port 21. When a request is received, it manages the input and establishes the connection. During the session, the server executes any commands sent by the FTP client. TCP is used as the transport layer protocol. FTP uses two types of connections to transfer data:

  1. Control connection (port 21)
  2. Data connection (in active mode port 20, in passive mode any port greater than 1024)

The division into a control connection and a data connection is efficient. This allows you to transfer commands and files independently of each other.

FTP supports two types of authentication:

  1. Anonymous (ftp or anonymous login, password - email)
  2. Authorized (username and password are different for each user)

When working via the FTP protocol, two modes can be set between the client and the server: active and passive. The control connection is the same for Active and Passive mode. The client initiates a TCP connection from a dynamic port (1024 - 65535) to port number 21 on the FTP server, after which authentication takes place. Further actions depend on which mode is selected.

In active mode, after authentication, the client also tells the server its port number (from dynamic range 1024 - 65535) so that the server can connect to the client to establish a data connection. The FTP server connects to the specified client port number using TCP port number 20 for data transfer.

In passive mode, after authentication, the server tells the client the TCP port number (from the dynamic range 1024 - 65535) to which it can connect to establish a data connection.

Thus, in active mode, the connection is initiated by the server, as it connects to the client. In passive mode, the initiator of the connection is the client.

Active mode is “harmful” for the client in that when a server connects to it on a random port, such a connection will most likely be blocked by a firewall on the client side. Thus, it is necessary to open ports on the client side, which leads to security holes. On the other hand, this mode will be useful for the server, since the well-known port 20 is used for data transfer.

The passive mode is "harmful" in turn for the server, but "beneficial" for the client. The client will make both connections to the server, but one of them will be to a random high port, such a connection will be blocked by the firewall on the server side.

Passive mode is used, as a rule, when there is a firewall between the client and the server.

Most popular FTP commands:

Team Description
USER Specify username
PASS Specify a password
LIST Viewing the contents of a directory
CWD Change current directory
RETR Transfer file from server to client
STOP Transfer file from client to server
TYPE Set transfer mode
DELE Delete a file
MDK Create directory
RMD Delete directory
PASV Use passive mode
QUIT Logging out and disconnecting

FTP has three transfer modes:

  1. Streaming - continuous transmission of data as a stream (no processing, processing is done by TCP)
  2. Block - FTP divides data into blocks (header, data field, file size in bytes) and transfers them to TCP
  3. Compression mode by a single algorithm

An FTP server is a “library” of files on a hosting, used to store files of various formats. The most popular ftp servers are vsftpd and proftpd. FTP servers are needed in order to host large amounts of data for public and private downloads. Servers are often used for anonymous (guest) access to open-source distributions of software, music, and photos. Access for anonymous users, as a rule, only allows you to browse directories and download the necessary information, but on some servers, on the contrary, there are special directories where any user can upload a file for sharing.

With non-anonymous access, there are more possibilities, but they are limited to the directory where access is granted.

Let's move on to setting up the server. We will work with such a scheme.

Both the administrator and the user will have access to the FTP server. Administrator and user have authorized access. In this case, it is necessary to configure access rights in such a way that the administrator has unlimited access, and the user has access only to his home directory. You also need to set up anonymous access.

In Ubuntu for DHCP servers the vsftpd daemon is available. Install the DHCP server, this is done with the command:

testServer$ sudo apt-get install vsftpd

By default, anonymous upload is disabled. You need to change the configuration in the /etc/vsftpd.conf file.

testServer$ sudo nano /etc/vsftpd.conf

We find the line “anonymous_enable” there and assign the value “Yes” to it. Given line is responsible for accessing the FTP server for anonymous users.

You also need to uncomment two lines: “write_enable” and “chroot_local_user”. The first line is responsible for the ability to write to the server, the second line blocks the ability of local users to climb to a directory higher than their home folder.

At the end of the configuration file, add two settings:

These settings set home folders for anonymous and local users.

We save the file configuration with the key combination Ctrl + X (when prompted to replace current file choose Yes). Next, you need to restart the FTP server with the command

testServer$ sudo service vsftpd restart

The next step is to create users.

Create a superuser with the command:

testServer$ sudo adduser superuser

Give him a password:

testServer$ sudo passwd superuser

We give him unlimited rights:

testServer$ sudo adduser superuser sudo

Create a regular user:

testServer$ sudo adduser user

Give him a password:

testServer$ sudo passwd user

Enter new UNIX password: 12345

Create a user group to manage folders:

testServer$ sudo addgroup groupl

testServer$ sudo nano /etc/group

Find the line "groupl" with Ctrl + W.

In this line we add our users superuser and user.

Create folders for users:

testServer$ sudo mkdir /srv/ftp/upload

testServer$ sudo mkdir /srv/ftp/superuser

testServer$ sudo mkdir /srv/ftp/user

Set permissions for folders:

testServer$ sudo chmod 700 /srv/ftp/superuser

testServer$ sudo chmod 770 /srv/ftp/user

testServer$ sudo chmod 575 /srv/ftp/upload

Changing folder owners:

testServer$ sudo chown superuser: /srv/ftp/superuser

testServer$ sudo chown user:groupl /srv/ftp/user

testServer$ sudo chown:groupl /srv/ftp/upload

Thus, we get the following picture:

  1. Only the superuser user has access to the superuser folder, he is also the owner of this folder
  2. The user folder has access to both user and superuser. This is due to the fact that we set the rights to 7 7 0. The second seven sets full rights for the groupl user group, to which we added superuser.
  3. Both user and superuser have full access to the upload folder. For everyone else, only read and execute permissions are set. 5 75 . 5 = 101 (in binary). 101 ~ r-x. That is, other users (which include anonymous) cannot write anything in the upload folder.

We check access rights and owners with the command:

testServer$ ls -l /srv/ftp

In order to check access to the FTP server, it is necessary in any browser in address bar dial:

ftp://172.16.1.2

IN this case we get as an anonymous user, because we do not enter a name and password.

We see three folders superuser/, upload/, user/. Since we logged in as an anonymous user, there is only access to the folder upload/.

To log in as superuser, type:

ftp:// [email protected]

Enter username: superuser, password: 12345 . Under superuser we get access to all folders.

Let's finally check the regular user. In order not to enter a username and password every time you log in, you can write the following in the address bar:

ftp://user: [email protected]

Under user we can only get into folders upload/ And user/. Go to folder superuser/ Access closed.

Support the project

Friends, the Netcloud website is developing every day thanks to your support. We plan to launch new sections of articles, as well as some useful services.

You have the opportunity to support the project and contribute any amount you see fit.

In this guide, we will show you how to install an FTP server on a VPS running Ubuntu. We will use the vsftpd server, which is considered the fastest and most secure FTP server for UNIX systems.

FTP or F ile T ransfer P rotocol is a protocol for receiving and transmitting files on the network. Using a client/server model and SSL/TLS security, FTP allows users to exchange files with remote computers safely, efficiently and securely by transferring data over the TCP/IP protocol.

FTP works like HTTP or SMTP, with the only difference being that it is responsible for the secure transfer of data from the sender to the recipient, rather than a web page from the server to the user or email through the Internet. This guide covers the creation of an FTP server on the OS Ubuntu versions 16.04.

Note: This guide is based on Ubuntu 16.04. But you can apply the same steps to create an FTP server on Ubuntu 14.04.

First of all, let's update all the packages before starting the installation of the vsftpd daemon. To do this, run the command:

Sudo apt-get update

Wait for all processes to complete and you will see a confirmation message:

Then install the vsftpd daemon with the following command:

sudo apt-get install vsftpd

You will receive a confirmation message, click Y And Enter to continue installation.

Once the installation is complete, make a backup of the original config file to start with a clean config file:

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.original

Now we can move on to the next step and configure the firewall.

Step 2 - Allowing FTP traffic on the firewall

To allow the FTP server deployed on Ubuntu OS to communicate with the outside world, you need to set up a path through the firewall. First, let's see if the firewall is enabled. Run the following command to determine the status:

Sudo ufw status

If you see a message like this:

Ufw: command not found

This means that the firewall is not installed and you can proceed to the next step.

If the output shows rules or a message that the firewall is active, you need to determine how it will process FTP traffic. Let's do the following, open ports 20 and 21 for FTP traffic; ports 40000-50000 will be reserved as a range of passive ports, which will eventually be set in the configuration file; port 990 will be used when TLS is enabled. Let's execute the following commands:

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

Now let's look at the status:

The result will look something like this:

Output Status : active To Action From -- -- -- -- -- -- 990 / tcp ALLOW Anywhere 20 / tcp ALLOW Anywhere 21 / tcp ALLOW Anywhere 40000 : 50000 / tcp ALLOW Anywhere 20 / tcp (v6 ) ALLOW Anywhere ( v6 ) 21 / tcp (v6 ) ALLOW Anywhere (v6 ) 990 / tcp (v6 ) ALLOW Anywhere (v6 ) 40000 : 50000 / tcp (v6 ) ALLOW Anywhere (v6 )

Now, all the necessary ports are open and available to us and we can move on to the next step.

Step 3 - Creating a User Directory

On the third step creating Ubuntu FTP server, you need to select a user who will connect via FTP. To do this, create a new user by running the following command:

sudo adduser alex

Fill in the password and other details when prompted. Ideally, from a security point of view, FTP should be limited to one special directory. Vsftpd uses chroot to create this protection. With chroot enabled, the local user is restricted to his home directory (by default). However, it may be that due to vsftpd's security, the user will not be able to create anything in the directory. We're not removing write permissions on the home directory, instead we'll make an ftp directory that behaves like a chroot along with retaining writability, allowing files to be stored. Use the following command to create an FTP directory:

sudo mkdir /home/alex/ftp

Set ownership:

sudo chown nobody : nogroup /home/alex/ftp

Finally, remove write permissions:

sudo chmod a -w /home/alex/ftp

Now, using the following command, check the permissions:

sudo ls -la /home/alex/ftp

At the output, we will see something like this:

total 8 dr - xr - xr - x 2 nobody nogroup 4096 Jun 29 11:32 . drwxr - xr - x 3 alex alex 4096 Jun 29 11:32 . .

In the next step, we will create a file containing the directories and their permissions:

sudo mkdir /home/alex/ftp/files sudo chown alex : alex/home/alex/ftp/files

And finally, add a test file to the directory that we will use while testing something:

echo "vsftpd sample file" | sudo tee /home/alex/ftp/files/sample. txt

Step 4 — Setting up vsftpd

To proceed with installing an FTP server on an Ubuntu VPS, we need to set up vsftpd and our FTP access. In this tutorial, we will allow a single user to connect via FTP using the local console. The two-step configuration required for this is already set in the configuration file ( vsftpd.conf). First check that the settings in the file match the following:

sudo nano /etc/vsftpd . conf. . . # Allow anonymous FTP? (Disabled by default). anonymous_enable=NO# # Uncomment this to allow local users to log in. local_enable = YES . . .

In the same file, continue deleting # turn on write_enable:

. . . write_enable = YES . . .

Chroot will also be uncommented to make sure that the user connected via FTP has access to files inside the allowed directory:

. . . chroot_local_user = YES . . .

A few new values ​​will also need to be added manually. You can just paste them at the end of the file. At first, user_sub_token add local_root to the directory path. This will allow the configuration to work with the current user and any other user that will be added later:

user_sub_token=$USER local_root=/home/$USER/ftp

To make sure that enough connections are available, we will limit the number of ports used in the config file:

pasv_min_port = 40000 pasv_max_port = 50000

In this guide, we plan to give access on an individual basis, so let's set the settings to give access only to users who are directly added to the list:

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

Flag userlist_deny is responsible for switching the logic, when it is set to “NO”, only those users that are on the list have access. Click when finished CTRL+X and confirm saving changes to the file.

Finally, let's continue creating and adding our user to the file:

echo "alex" | sudo tee - a / etc / vsftpd . userlist

Check that the user is actually active by running the command:

cat /etc/vsftpd. userlist

The output should be " Alex”, as shown in the screenshot:

Restart the daemon using the following command to start the configuration changes:

sudo systemctl restart vsftpd

Step 5 - Making Secure FTP

By default, FTP does not do any data encryption, so we will use TLS/SSL to take care of security. As a first step, we need to create SSL certificate and use it for ubuntu protection FTP server. To get started, run the following command:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem

Flag - days makes the certificate valid for a year and we include the 2048-bit RSA private key in the same command. When prompted for the required data, enter it in the provided field.

After creating the certificate, open it again configuration file:

sudo nano /etc/vsftpd.conf

At the end of the file there is a line with " _rsa". Comment out these two lines:

# rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem # rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

Instead, we will direct the config file to the certificate we created. Add these lines:

rsa_cert_file=/etc/ssl/private/vsftpd.pem rsa_private_key_file=/etc/ssl/private/vsftpd.pem

Now we will enable SSL and make sure that only users with SSL enabled can communicate with us. Change the value ssl_enable on YES:

ssl_enable = YES

Now add the following lines to continue creating the protection (this will prevent any anonymous connections using SSL):

allow_anon_ssl=NO force_local_data_ssl=YES force_local_logins_ssl=YES

Set up TLS using:

ssl_tlsv1=YES ssl_sslv2=NO ssl_sslv3=NO

Here we will add 2 more options. Firstly, SSL reuse will not be necessary because it can lead to breaks for a large number of clients. Secondly, we will use a highly secure encryption code, which will mean that the key length is equal to (or greater than) 128 bits.

Require_ssl_reuse=NO ssl_ciphers=HIGH

Let's restart again for the changes to take effect:

sudo systemctl restart vsftpd

Wonderful! Here you have configured the FTP server on your Ubuntu VPS to work with the SSL/TLS protocol.

Step 6 - Checking the connection using FileZilla

Today FTP clients support setting up TLS encryption, so this is a great opportunity to check if our Ubuntu FTP server is working properly. To test the connection, we will use . To get started, launch FileZilla by clicking on the icon site manager.

Click on the button new site in the window that appears, start filling in the information about the Ubuntu FTP server.

Fill in the required fields with information about the newly created Ubuntu FTP server. Since we configured it using TLS, we can check the encryption setting in “ explicit FTP over TLS” position. The final settings window looks like this:

Once set, press Connect and a window will appear asking you to enter the FTP user password.

Finally, you will need to validate the SSL certificate on your Ubuntu VPS FTP server.

After confirmation, the root directory with the test file will appear on your screen.

This is all! Now you can perform any file transfer from your computer to Ubuntu FTP server and vice versa.

Conclusion

In this tutorial, we've gone through a step-by-step process of creating a secure way for a local user to transfer files via FTP with SSL/TLS on an Ubuntu FTP server. We also tested the connections using FileZilla to make sure everything works.

From time to time everyone system administrator there is a need for an FTP server, most often this is due to the need to ensure the exchange of information in automatic mode between applications, for example, when auto-exchanging a distributed 1C infobase, or for accessing files on a web server. Today we will tell you how to create such a server on the Ubuntu platform in less than half an hour.

But first, some theory. The FTP protocol (File Transfer Protocol) is intended, as the name suggests, for transferring files and appeared in 1971, but despite its advanced age, it continues to be widely used to this day. Although its use today is more technical in nature, end-users typically use a browser and HTTP protocol to access data. The advantages of FTP include the ability to resume the file when the connection is broken and the ability to equally easily read files and write them. But there are also disadvantages, the most serious is low security, so this issue should be given the closest attention.

FTP, like PPTP, uses different connections for transferring commands and transferring data. When initiating a connection, the client sends control commands to port 21 of the server, which in turn establishes an outgoing data connection on port 20, the port on the client side is determined as a result of negotiation. However, when the client is behind NAT, the connection cannot be established in this way, therefore, an additional FTP passive mode (passive mode) was developed, when the data connection is established not by the server, but by the client, however, with the parameters specified by the server. These points should be taken into account when forwarding FTP and when setting up a network filter.

For our server we will use vsftpd- simple, fast and secure FTP server. Since it will serve both external and internal network, then it makes sense to add this role to our . Server installation is extremely simple:

apt-get install vsftpd

The server is configured through the configuration file /etc/vsftpd.conf he has simple structure, is well commented and allows you to set up the server without any instructions with minimal knowledge. Consider its main parameters.

The server can be started constantly, as a service, or start when necessary, the first option is more suitable for us:

Listen=YES

This option has a mutually exclusive entry, which should be changed to:

Listen_ipv6=NO

Allow only local users to log in:

Anonymous_enable=NO
local_enable=YES

Allow users to write files and tell the server to automatically expose necessary rights(755 for folders and 644 for files):

Write_enable=YES
local_umask=022

If you want to set a different set of rights: 775 and 664, then the umask must be equal to 002.

By default, the server uses GMT time, so that files are set to the time in your time zone, use the option:

Use_localtime=YES

Enable the log of uploaded and downloaded files:

Xferlog_enable=YES

Allow the server to establish data connections on port 20 (active mode):

Connect_from_port_20=YES

The following options set the location and format for storing logs:

xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES

Set session timeouts:

idle_session_timeout=600
data_connection_timeout=120

Also, for security reasons, we isolate the user in his home directory and immediately allow writing to his root:

chroot_local_user=YES
allow_writeable_chroot=YES

For correct work with text data, you can enable ASCII support, this will allow you to transfer text file With Windows systems on UNIX (Linux) it is correct to change the line break characters from CR+LF to LF to display the content correctly and reverse the conversion when passing it back.

Ascii_upload_enable=YES
ascii_download_enable=YES

You can enable only one option, for uploading or downloading. Please note that when transferring a binary file in ASCII mode, the latter may be corrupted.

Quite an interesting option:

ls_recurse_enable=YES

It allows recursive browsing of directories, on the one hand it is convenient, on the other hand it can cause a large load on the server if, for example, you get a listing of a directory containing a large number of files and directories.

We leave all other options by default, although you can edit the server greeting by writing whatever you like there:

Ftpd_banner=Welcome to Roga i Kopyta LLC FTP

At the end of the configuration file, we will set the settings for the passive mode, it is recommended to explicitly set the ports so that you can specify them during forwarding if the server is behind NAT or in firewall rules:

pasv_enable=YES
pasv_min_port=62000
pasv_max_port=62999

Restart the server (this should be done every time after making changes to the configuration):

Service vsftpd restart

and try to connect with any FTP client using the credentials of an existing user. We need to get into his home directory and be isolated in it.

In case of an error related to the incorrect operation of vsftpd and the seccomp security system:

500 OOPS: prctl PR_SET_SECCOMP failed

add an undocumented option to the file:

seccomp_sandbox=NO

However, remember that FTP is an insecure protocol, so letting any local user into the server, as is done now, is not the best the best option. To avoid this situation, vsftpd has a built-in user control mechanism. Let's add an option to the configuration file:

userlist_enable=YES

and create a user list file:

Touch /etc/vsftpd.user_list

Default vsftpd forbids access to the server to users specified in this list even before entering the password, i.e. implements the principle allowed to all who are not prohibited. But it would be much better to implement a different approach: forbidden to everyone who is not allowed. Those. allow access only to specified users. To do this, add the option:

userlist_deny=NO

Now only explicitly specified users will have access to the FTP server, they should be specified in vsftpd.user_list one per line, for example:

Ivanov
petrov

Unless otherwise specified, when connecting via FTP, users are taken to their home directory. This is not always convenient, often you need to redirect them to a different directory. If this is a shared folder, say /var/ftp, then you can set the option:

Local_root=/var/ftp

Which will redirect all users to the specified directory and isolate them there.

This is the simplest situation, real tasks are usually more complicated, let's say we need to set the user Ivanov as the root directory /var/www/example1.com, and Petrov /var/www/example2.com so that each of them works with its own folder. For these purposes, you can use another feature of vsftpd - user settings that override the settings of the main configuration file.

To do this, add the option:

User_config_dir=/etc/vsftpd_user_conf

Then we will create the directory itself

Mkdir /etc/vsftpd_user_conf

To ask the user own settings in this directory, create a file with the name of the user and add the necessary options to it. Changes are applied without restarting the FTP server the next time the client connects.

Let's create a file with settings for Ivanov:

Tocuh /etc/vsftpd_user_conf/ivanov

and add an option to it:

local_root=/var/www/example1.com

The next time you connect, the user's root directory will change to the specified one. Also in this file we can set any personal options, for example, another umask or file permissions. However, we cannot use global settings here: connection, logging, authentication options, they will simply be ignored.

If you need to hide the real owners of files and folders, you can use the option:

Hide_ids=YES

In this case, ftp:ftp will be specified instead of real owners and groups, this can be useful in case of a public server or if there are unauthorized persons in the user list to whom you do not want to disclose the real user names of your system.

As you can see, we really created a working FTP server in less than half an hour.

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE: