Store vsftpd + mysql's Virtual User Configuration Record-PHP Tutorial

Source: Internet
Author: User
Store the Virtual User configuration records of vsftpd + mysql. How to solve vsftpd + mysql Virtual User configuration records stored in Qibao: 1. install vsftpdyuminstallvsftpd and ok2. the pam_mysql component is required. here 3. for the compilation parameters, see INSTALL. I am here to store the virtual user configuration records of vsftpd + mysql.
Solution
1. install vsftpd yum install vsftpd.
2. the pam_mysql component is required. here
3. for compilation parameters, see INSTALL. here we use a parameter withmysql =/usr/local/amp/mysql5.
4. create a mysql database, table db = vsftpd table = users (username, userpass, homedir), and create a corresponding mysql account vsftpd (you can also use the root account or existing account)
5. modify/etc/pam. d/vsftpd adds two new lines of auth required/usr/lib/security/pam_mysql.so user = vsftpd passwd = vsftpd host = localhost db = vsftpd table = users usercolumn = username passwdcolumn = userpass

Account required/usr/lib/security/pam_mysql.so user = vsftpd passwd = vsftpd host = localhost db = vsftpd table = users usercolumn = username passwdcolumn = userpass


6. create a folder to store the virtual user configuration file. in/etc/vsftpd/virtual, I put a configuration file template named _ tpl write_enable = YES.

Anon_mkdir_write_enable = YES

Anon_upload_enable = YES

Anon_other_write_enable = YES


It means a homedir is missing.
7. open/etc/vsftpd. conf and set it to # Be sure to have

Listen = YES

# Listen_port = 10021

Connect_from_port_20 = YES

# Server prompt

Ftpd_banner = Welcome to My FTP server.

# Disable anonymous access

Anonymous_enable = NO

Local_enable = YES

Write_enable = NO

Anon_upload_enable = NO

Anon_mkdir_write_enable = NO

Anon_other_write_enable = NO

Chroot_local_user = YES

Guest_enable = YES

# The account used by the Virtual User. if it is root, the file owner you Upload will also be root,

# In general security situations, set up a separate vsftpd user, just like an independent mysql User

Guest_username = root

Pasv_min_port = 30000

Pasvanderbilt max_port = 30999

# For the vsftpd under/etc/pam. d/, see section 6th.

Pam_service_name = vsftpd

# Virtual user configuration file directory

User_config_dir =/etc/vsftpd/virtual

Xferlog_enable = YES

# Xferlog_file =/var/log/vsftpd. log

Xferlog_file =/data1/logs/vsftpd. log

Anon_world_readable_only = NO

Anon_umask = 022

File_open_mode = 0777

Local_umask = 022

#20080811 last modify

Data _ connection_timeout = 120


Note that the values of local_umask and anon_umask
After uploading your file, the permission value is 777 local_umask, that is, 022 in the previous example. After uploading, the file permission will be 755.
8./etc/vsftpd restart
9. I still have two shells here, but my bash is very stupid. if the judgment is wrong
Add ftp users #! /Bin/bash

Clear

Echo "******************************"

Echo "* Add vsftpd User Script *"

Echo "* AnVy 2008.0516 *"

Echo "******************************"



Echo "Enter user account: [Enter Key]"

Read username

Echo "Username is $ username, Now Enter the password: [Enter Key]"

Read userpass

Echo "Asign the user's ftp home directory: [Enter Key]"

Read home

Echo "create this dir? [Y/n]:"

Read $ cd

If [$ cd = "y"]

Then

Mkdir $ home

Fi

# Chown R www: www $ home

/Usr/local/amp/mysql5/bin/mysql uvsftpd pvsftpd <
Use vsftpd;

Replace into users (username, userpass, homedir) values ('$ username',' $ userpass', '$ home ');

\ Q

EOF

Cp/etc/vsftpd/virtual/_ tpl/etc/vsftpd/virtual/$ username

# Append the home directory configuration parameters in the user configuration file

Echo "local_root = $ home">/etc/vsftpd/virtual/$ username

Echo "$ username with homedir = $ home was added ."


Ftp account list and user deletion #! /Bin/bash

Clear

Echo "******************************"

Echo "* Add vsftpd User Script *"

Echo "* AnVy 2008.0516 *"

Echo "******************************"

Echo "UserList :"

/Usr/local/amp/mysql5/bin/mysql uvsftpd pvsftpd <
Use vsftpd;

Select * from users;

\ Q

EOF

Echo "Delete user account: [Enter Key]"

Read username

/Usr/local/amp/mysql5/bin/mysql uvsftpd pvsftpd <
Use vsftpd;

Delete from users where username = '$ username ';

\ Q

EOF

Unlink/etc/vsftpd/virtual/$ username

Echo "$ username without homedir was removed ."


The above settings can be used to easily implement virtual user allocation, and I do not know much about advanced settings.
In this way, you can open a vsftpd account by entering the user name, password, and home directory, and the file upload permission is 755, which is fully available.

[]
Attachment: you cannot download or view attachments in your user group.

D8888D reply content
\ Q must be replaced with a halfwidth
D8888D reply content
Yes, I didn't get this automatic account during configuration, but I just manually configured it. it doesn't always change.

Solution 1. install vsftpd yum INSTALL vsftpd on OK 2. the pam_mysql component is required. here 3. Compile the parameters and check install me here...

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.