Vsftpd virtual user settings on Ubuntu

Source: Internet
Author: User

Target

First, assume that you have installed vsftpd and created the following three subdirectories in the/home/vsftpd directory:

        Dbzh1
        Dbzh2
        Dbzh3

Next, we will create three virtual users. The passwords will be followed by the username & quot; 00 & quot;

        Db1
        DB2
        Db3

Make

        The main directory of user db1 is dbzh1, which has only read-only permission.
        The main directory of your DB2 database is dbzh2, which has only the read-only permission.
      The main directory of user db3 is dbzh3, which has all Permissions

Create a virtual user database

Create the login file loguser.txt

The format is as follows:

User_id

Password

Therefore, the content of our/home/loguser.txt file is

Db1

Db100

DB2

Db200

Db3

Db300
Generate Database

If you have not installed libdb4.6-util or you do not know whether it is installed, run the following command first.

Sudo apt-Get install db4.6-util

Then, we execute

Sudo db4.6 _ load-T-t hash-f/home/loguser.txt/etc/vsftpd_login.db

Finally, set the database file access permission.

Sudo chmod 600/etc/vsftpd_login.db

Configure the PAM File

Edit the/etc/PAM. d/vsftpd. vu file to add the first two lines of the original file:

Auth required/lib/security/pam_userdb.so DB =/etc/vsftpd_login

Account required/lib/security/pam_userdb.so DB =/etc/vsftpd_login

        The database vsftpd_login we created in the previous step is used here
      The created virtual user will use Pam for verification. This is enabled through the statement pam_service_name = vsftpd. vu in the/etc/vsftpd. conf file. You will find it later.

Create a local system user for a virtual user

Create a new system user vsftpd. the user's home directory is/home/vsftpd, and the user logon terminal is set to/bin/false (even if the user cannot log on to the system)

Sudo useradd vsftpd-D/home/vsftpd-S/bin/false
Arrears
Sudo chown vsftpd: vsftpd/home/vsftpd

/Etc/vsftpd. conf

Create/etc/vsftpd. conf as needed. Make sure that the following settings are included:

Listen = Yes

Anonymous_enable = No

Dirmessage_enable = Yes

Xferlog_enable = Yes

Xferlog_file =/var/log/vsftpd. Log

Xferlog_std_format = Yes

Chroot_local_user = Yes

Guest_enable = Yes

Guest_username = vsftpd

User_config_dir =/etc/vsftpd_user_conf

Pam_service_name = vsftpd. vu

Local_enable = Yes

Secure_chroot_dir =/var/run/vsftpd

So far, all three of our users can work, but their root directories are now/home/vsftpd, with the same permissions. So how can we achieve our goal?

/Etc/vsftpd_user_conf

In the above configuration, there is such a line

User_config_dir =/etc/vsftpd_user_conf

Now, we need to put the configuration files of each user in the/etc/vsftpd_user_conf directory.

Sudo mkdir/etc/vsftpd_user_conf

CD/etc/vsftpd_user_conf
Foreign Language House
Sudo touch db1 DB2 db3

The content in the db1 file is as follows:

Local_root =/home/vsftpd/dbzh1

Similarly, content in the DB2 File

Local_root =/home/vsftpd/dbzh2

So what about db3? It's actually quite simple.

Write_enable = Yes

Anon_world_readable_only = No

Anon_upload_enable = Yes

Anon_mkdir_write_enable = Yes

Anon_other_write_enable = Yes

Local_root =/home/vsftpd/dbzh3

Note that there must be no space. Otherwise, an error will be prompted during logon. I also have problems here,

Can it be?

Restart vsftpd and we can see the effect ^_^.

/Etc/init. d/vsftpd START | restart

500 Oops: cannot change directory:

In Linux, when FTP is enabled, the following problems occur: 500 Oops: cannot change directory:

If many Google users execute this command, OK setsebool ftpd_disable_trans 1 service vsftpd restart

But this problem occurs during execution. cocould not change active booleans: Invalid Boolean

After searching for a long time, I finally solved the problem.

Setsebool-P ftp_home_dir = 1

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.