Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure vsftp virtual users in linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to configure vsftp virtual users in linux. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Generate a virtual user password library file. To create this password library file, you first need to generate a text file. The format of the file is as follows, odd behavior user name, even behavior password:

# viaccount.txt

Ylg

1234

Zhanghong

4321

Gou

5678

2. Generate the password library file and modify its permissions:

# db_load-T-thash-f./account.txt/etc/vsftpd/account.db

# chmod600/etc/vsftpd/account.db

3. Create a new PAM file for the virtual user. Add the following two lines:

# vi/etc/pam.d/vsftp.vu

Authrequired/lib/security/pam_userdb.sodb=/etc/vsftpd/account

Accountrequired/lib/security/pam_userdb.sodb=/etc/vsftpd/account

4. Create a virtual user, set the directory that the user wants to access, and set the permissions for the virtual user to access:

# useradd-d/home/ftpsitevirtual_user

# chmod700/home/ftpsite

After this step, / home/ftpsite is the home directory of the virtual_user user, who is also the owner of the ftpsite directory. Except for the root user, only that user has read, write, and execute permissions to the directory.

5. Edit the / etc/vsftpd/vsftpd.conf file so that the entire contents of the file are as follows (without comments):

Anonymous_enable=NO

Local_enable=YES

Local_umask=022

Xferlog_enable=YES

Connect_from_port_20=YES

Xferlog_std_format=YES

Listen=YES

Write_enable=YES

Anon_upload_enable=YES

Anon_mkdir_write_enable=YES

Anon_other_write_enable=YES

One_process_model=NO

Chroot_local_user=YES

Ftpd_banner=WelcomtomyFTPserver.

Anon_world_readable_only=NO

Guest_enable=YES

Guest_username=virtual_user

Pam_service_name=vsftp.vu

In the above code, guest_enable=YES means to enable the virtual user; guest_username=virtual maps the virtual user to the local user, so that the virtual user can log in to the directory of the local user virtual / ftpsite;pam_service_name=vsftp.vu and specify that the configuration file of PAM is vsftp.vu.

6. Restart VSFTP:

# servicevsftpdrestart

7. Test with the virtual user gou (there is no such account in Linux):

# ftp127.0.0.1

Connectedto127.0.0.1 (127.0.0.1).

220WelcomtomyFTPserver.

Name (127.0.0.1:root): gou

331Pleasespecifythepassword.

Password:

230Loginsuccessful.Havefun.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

In the virtual FTP server, the permissions of individual users can also be set. You can do this by adding the following line to the / etc/vsftpd.conf file:

User_config_dir= user profile directory

Then create the corresponding user profile under the user profile directory, such as a profile for the above user named gou (assuming the profile directory is / etc/vsftpd_user_conf):

# vi/etc/vsftpd_user_conf/gou

Write_enable=NO

Anono_upload_enable=NO

8. Virtual user personal directory settings

You can find that no matter which virtual user is logged in, the directory is / home/ftpsite, that is, the home directory of the guest user. Next, how to set up your own directory for each virtual user.

One way to do this is to specify the virtual user's home directory using the local_root option in the virtual user's personal profile. Take gou as an example, on the basis of the previous step, first add to the / etc/vsftpd_user_conf/gou file:

Local_root=/home/ftpsite/gou

Create a new gou directory under / home/ftpsite and set the permission to virtual_user:

9. To add a FTP user

1. Add a user name and password to account.txt

two。 Run the following command to add the user name and password to the database

Db_load-T-thash-f./account.txt/etc/vsftpd/account.db

3. Create a new folder in / home/ftpsite, as specified by the user

4. Create a new file with the same user name in the vsftpd_user_conf folder and add

Local_root=/home/ftpsite/ user name

The above is how to configure vsftp virtual users in linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report