VSFTP + MySQL virtual user configuration process

Source: Internet
Author: User
Tags gz file

VSFTPD is a secure and fast FTP server in UNIX/Linux and has been used by many large websites. VSFTPD supports saving user names and passwords in database files or database servers. VSFTPD calls this form of user as a virtual user. Compared with FTP local (system) users, virtual users are only dedicated users of the FTP server. Virtual users can only access the resources provided by the FTP server, which greatly enhances the security of the system. Compared with anonymous users, a virtual user requires a user name and password to obtain files on the FTP server. This increases the manageability of users and downloads. For FTP sites that require the download service, but do not require everyone to download them anonymously, you need to manage the download users and take into account host security and convenient management, virtual users are an excellent solution. This article describes how to save the virtual user name and password of VSFTPD on RedHat Linux 9 on the MySQL database server.
  
I. VSFTPD Installation

Currently, the latest version of VSFTPD is 1.2.0. The official website is ftp://vsftpd.beasts.org/users/cevans/vsftpd-1.2.0.tar.gz. Before installation, make the following preparations:
  
The "nobody" user is required in the default VSFTPD configuration. Add this user to the system. If the user already exists, the useradd command prompts accordingly.
[Root @ hpe45 root] # useradd nobody
Useradd: user nobody exists
  
The "/usr/share/empty" directory is required in the default VSFTPD configuration. In the system, if the directory already exists, the mkdir command prompts accordingly.
[Root @ hpe45 root] # mkdir/usr/share/empty/
Mkdir: cannot create directory '/usr/share/empty': File exists
  
When VSFTPD provides anonymous FTP services, you need an "ftp" user and a valid anonymous directory.
[Root @ hpe45 root] # mkdir/var/ftp/
[Root @ hpe45 root] # useradd-d/var/ftp
The subsequent operations are useful for the existence of ftp users.
[Root @ hpe45 root] # chown root. root/var/ftp
[Root @ hpe45 root] # chmod og-w/var/ftp
  
After the above preparations are completed, we can start to compile the source code. Assume that the downloaded vsftpd-1.2.0.tar.gz file is in the/root directory and run the following command:
[Root @ hpe45 root] # tar zxvf vsftpd-1.2.0.tar.gz
[Root @ hpe45 root] # cd vsftpd-1.2.0
[Root @ hpe45 vsftpd-1.2.0] # make
[Root @ hpe45 vsftpd-1.2.0] # make install
  
The above "make install" Command copies compiled binary files and manuals to the corresponding directory. You may need to manually perform the following copy on rh93:
# Cp vsftpd/usr/local/sbin/vsftpd
[Root @ hpe45 vsftpd-1.2.0] # cp vsftpd. conf.5/usr/local/share/man/man5
[Root @ hpe45 vsftpd-1.2.0] # cp vsftpd.8/usr/local/share/man/man8
  
Next, we will copy a simple configuration file for later modification.
[Root @ hpe45 vsftpd-1.2.0] # cp vsftpd. conf/etc
# Cp RedHat/vsftpd. pam/etc/pam. d/ftp
Copy the PAM Authentication file to allow local users to log on to VSFTPD.
# Cp RedHat/vsftpd. pam/etc/pam. d/ftp
  
2. Create a guest user

VSFTPD uses PAM to verify virtual users. Because the user name/password of a virtual user is saved separately, during verification, VSFTPD needs to use the identity of a system user to read database files or database servers for verification, this is the guest user of VSFTPD. This is just like Anonymous Users also need a system user ftp. Of course, we can also regard the guest user as the representative of the virtual user in the system. Add the vsftpdguest user to the system as the guest of VSFTPD.
[Root @ hpe45 vsftpd-1.2.0] # useradd vsftpdguest
After a virtual user logs on, the user is located in the/home/vsftpdguest directory of vsftpdguest. To log on to other directories such as/var/ftp, modify the vsftpdguest directory.
  
3. Set the VSFTPD configuration file

In the/etc/vsftpd. conf file, add the following options:
Guest_enable = YES
Guest_username = vsftpdguest
  
Run the following command to run VSFTPD in the background:
[Root @ hpe45 vsftpd-1.2.0] #/usr/local/sbin/vsftpd &
  
4. Save the virtual user in the MySQL database server

We create the database vsftpdvu, table users, field name and passwd to save the virtual user name and password, and add two virtual users xiaotong and xiaowang.
  
[Root @ hpe45 vsftpd-1.2.0] # mysql-p
Mysql> create database vsftpdvu;
Mysql> use vsftpdvu;
Mysql> create table users (name char (16) binary, passwd char (16) binary );
Mysql> insert into users (name, passwd) values ('xiaotong ', password ('qqmywife '));
Mysql> insert into users (name, passwd) values ('xiaowang ', password ('ttmywife '));

  • Three pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.