The following articles mainly describe the specific practices of vsftpd + MySQL virtual users in Debian Linux. I saw the information about vsftpd + MySQL virtual users in Debian Linux on the relevant website two days ago, let's share it with you. Today, I had nothing to do with ftp. The reason is very simple: to put what I can see elsewhere
The following articles mainly describe the specific practices of vsftpd + MySQL virtual users in Debian Linux. I saw information about vsftpd + MySQL virtual users in Debian Linux on the relevant website two days ago, I think it's good. I just want to share it with you. Today, I had nothing to do with ftp. The reason is very simple: to put what I can see elsewhere
The following articles mainly describe the specific practices of vsftpd + MySQL virtual users in Debian Linux. I saw information about vsftpd + MySQL virtual users in Debian Linux on the relevant website two days ago, I think it's good. I just want to share it with you.
Today, I had nothing to do with ftp. The reason is very simple: to put the good stuff that can be seen elsewhere on my machine, hey! It is not easy to select an ftp server in linux. After a bit of thinking, I chose vsftpd, the reason is that it is known as the safest ftp server in linux, and there are still many large websites that use it as a server (this makes it easy to use :)).
In order to prevent others from peeking at my password and logging on to my machine, I hate the fact that there are so many users in the system (like displaying my own hands ), therefore, I decided to use virtual users because MySQL (the best combination with PHP) is installed in the machine ), so I want to put vsftpd + MySQL virtual user data in MySQL (the best combination with PHP). Well, let's get started here. Next, let's get started!
Step 1:
Install vsftpd
Apt-get install vsftpd (Debian is awesome !)
The system automatically generates a configuration file and an ftp user for anonymous users. vsftpd uses pam to verify virtual users because vsftpd + MySQL virtual user information is stored in the database, therefore, we also need a local user who can read the database content and set its local directory:
- #mkdir /var/ftp
- #useradd -d ftpguest /var/ftp
- #chown ftpguest.nogroup /var/ftp
Step 2: Install MySQL (the best combination with PHP)
Apt-get install MySQL (the best combination with PHP)-server MySQL (the best combination with PHP)-clent
Create a database and add users
- # MySQL (the best combination with PHP)-p MySQL (the best combination with PHP)> create ftpu;
- MySQL (best combination with PHP)> use ftpu;
- MySQL (best combination with PHP)> create table user (name char (20) binary, passwd char (20) binary );
- MySQL (best combination with PHP)> insert into user (name, passwd) values ('test1', password ('20140901 '));
- MySQL (best combination with PHP)> insert into user (name, passwd) values ('test2', password ('20140901 '));
- MySQL (best combination with PHP)> quit
- Enable ftpguest to access ftpu and table user:
- # MySQL (the best combination with PHP)-u root MySQL (the best combination with PHP)
-P MySQL (the best combination with PHP)> grant select on ftpu. user to ftpguest @ localhost identified by '123 ';
MySQL (best combination with PHP)> quit
Step 3: Because vsftpd is verified by PAM
Therefore, we also need a MySQL (the best combination with PHP) package verified by PAM. In Debian, it is called libpam-MySQL (the best combination with PHP)
Apt-get install libpam-MySQL (best combination with PHP)
Enable pam verification For vsftpd:
- #vi /etc/pam.d/vsftpd
Comment out the previous content and add the following content:
Auth required pam_MySQL (best combination with PHP). so user = ftpguest passwd = 123456 host = localhost db = ftpu table = user usercolumn = name passwdcolumn = passwd crypt = 2
Account required pam_MySQL (best combination with PHP). so user = ftpguest passwd = 123456 host = localhost db = ftpu table = user usercolumn = name passwdcolumn = passwd crypt = 2
The above content should be clear. The crypt = 2 indicates something that has passed the password () secret of MySQL (the best combination with PHP!
Step 4: Modify the vsftpd. conf file
- #vi /etc/vsftpd.conf
Join:
- Uest_enable = yes
- Guest_username = ftpguest
- # Indicates that ftpguest is a virtual user of vsftp.
- Virtual_use_local_privs = yes
-
Vsftpd + MySQL virtual users have the same permissions as local users
- write_enable=yes
- anon_upload_enable=yes
- anon_other_write_enable=yes
Allows virtual users to upload, modify, and delete files.
- chroot_local_user=yes
Virtual users can only access their own directories.
- anonymous_enable=no
- local_enable=yes
Disable Anonymous user access and enable local user access
Step 5:
The fourth step has already been completed, but I thought about it later. No, if every upload is different, how can I manage the directory in a mess, can I create a directory for each vsftpd + MySQL virtual user? For example, place the files uploaded by music users in ~ /Music, put the File Uploaded By the doc user in ~ /What about doc?
Yes! Of course. How can I do this?
First, add two vsftpd + MySQL virtual users (music and doc) to the database:
- #mkdir /etc/vsftpd_user_conf
- #cd /etc/vsftpd_user_conf
- #touch music
- #echo "local_root=/home/username/music" > music
- #touch doc
- #echo "local_root=/home/username/doc" > doc
- #mkdir /home/username/music
- #chown ftpguest.nogroup /home/username/music
- #chmod 600 /home/username/music
- #chown ftpguest.nogroup /home/username/doc
- #chmod 600 /home/username/doc
Add user_config_dir =/etc/vsftpd_user_conf to vsftpd. conf?