Linux to build FTP server with vsftpd

  
How to use vsftpd to build FTP server under Linux, what are the characteristics of the built FTP server? This article will give a detailed introduction.
vsftpd is an abbreviation for "very secure FTP daemon", and security is one of its biggest features. Vsftpd is the name of a server running on a UNIX-like operating system. It can run on systems such as Linux, BSD, Solaris, HP-UNIX, etc. It is a completely free, source code ftp server software that supports many other Features not supported by the FTP server. For example: very high security requirements, bandwidth limitations, good scalability, ability to create virtual users, support for IPv6, high speed, etc.
This article uses RedHat Linux 9.0 as an example to introduce how to install and configure the vsftpd server.
Install server program
program download address: ftp://vsftpd.beasts.org/users/cevans/, the latest version is 2.0.3, the source file name is vsftpd-2.0.3.tar.gz .
1. Before the installation:
Before installation, we should look at the user "nobody" and the directory "/usr/share/empty". If it does not exist, you need to create this user and directory.
[root@localhost root]# useradd nobody
[root@localhost root]# mkdir /usr/share/empty
If you want to allow anonymous access, you also need to create an ftp user and set its home directory Is /var/ftp. These have been set by default in RedHat Linux 9.0, just create a /var/ftp directory.
[root@localhost root]# mkdir /var/ftp
For security, the directory "/var/ftp" should not belong to the user "ftp" and should not have write access. Here, we make the following settings:
[root@localhost root]# chown root.root /var/ftp
[root@localhost root]# chmod 755 /var/ftp
2. Start the installation:
Log in to the Linux system as an administrator and copy vsftpd-2.0.3.tar.gz to the /root directory.
[root@localhost root]# tar xzvf vsftpd-2.0.3.tar.gz
[root@localhost root]# cd vsftpd-2.0.3
[root@localhost vsftpd-2.0.3] # make
[root@localhost vsftpd-2.0.3]# make install
3. Installation follow-up
Because of the source code installation, many of the necessary configuration files are not copied to the system and need to be copied manually.
Copy configuration file:


[root@localhost vsftpd-2.0.3]# cp vsftpd.conf /etc
Copy pam verification file: (Most users using vsftpd are using the source) After the code is installed, you will encounter the problem that anonymous users can log in, and local users can't log in anyway. The reason is that vsftpd uses PAM authentication, and you need to copy a verification file for local users to access.)
[root@localhost vsftpd-2.0.3]# cp RedHat/vsftpd.pam /etc/pam.d/ftp
vsftpd configuration
vsftpd server configuration file is /etc/vsftpd.conf, its configuration options More, here I only choose a few common configuration options.
1. Anonymous user access is prohibited.
anonymous_enable=NO
2. Allow local users to log in and allow them to upload files.
local_enable=YES
write_enable=YES
For the above options to take effect, you must copy a pam verification file to /etc/pam.d and rename it to ftp. Of course, you can change to other names, but you must change the value of pam_service_name. The default is ftp.
3. Lock local users in the home directory and not switch to the previous directory.
chroot_local_user=YES
4. Some users are prohibited from logging in to the server through ftp.
If local_enable=YES is set, all users, including root, can also log in to the server via ftp. For security reasons, some users need to be restricted.
There are three options in vsftpd.conf:
userlist_deny=YES/NO
userlist_enalbe=YES
userlist_file=/etc/vsftpd.user_list
If userlist_deny=YES, /etc/vsftpd The username listed in .user_list is not allowed to log in to the ftp server; if userlist_deny=NO, the username listed in /etc/vsftpd.user_list is allowed to log in to the ftp server.


We only need to create the vsftpd.user_list file in the /etc directory. The file content is the username that allows login or login, and each user has one line.
5. Users are prohibited from modifying the permissions of files or folders via FTP.
chmod_enable=NO (default is YES)
6. Set the umask value of the file or folder uploaded by the local user.
local_umask=022 (default is 077)
The value of umask is set to 022. If the file is uploaded, the permission will be changed to 644, and if it is a folder, the permission will be changed to 755. When uploading a web page, if it is set to 077, there will be a problem that the user does not have permission to access the webpage, so it is recommended to set the value of umask to 022.
7. Add a user who can only log in to the server from ftp and cannot log in locally. Create a user ftpuser below, do not allow logging in locally, and create a password for that user. //This article comes from the computer software and hardware application network www.45it.com
[root@localhost root]# useradd –g ftp –s /sbin/nologin ftpuser
[root@localhost root]# passwd ftpuser
Changing password for user ftpuser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
8. Let the vsftp server limit the total number of connections and the maximum number of connections per IP.
#Maximum 100 client connections allowed at the same time
max_clients=100
#Up to 3 threads per ip address
max_per_ip=3
vsftpd has many options in the configuration file, but Personally think that if you are setting up a simple ftp server, the above options are sufficient.

Copyright © Windows knowledge All Rights Reserved