Add vsftpd virtual account under CentOS.

Source: Internet
Author: User
I am a Linux Cainiao. I recently used ftp operations in my project, but I am helpless. I have nothing to worry about. I need to start from scratch and search for various Baidu and materials. Finally, the service was set up and accessed smoothly. Here we will summarize the two items for future use. There are three methods to log on to FTP: Anonymous logon, local logon, and virtual logon. Anonymous logon: use the default user name when logging on to FTP, usually ftp or anonymous. Local User Login

I am a Linux Cainiao. I recently used ftp operations in my project, but I am helpless. I have nothing to worry about. I need to start from scratch and search for various Baidu and materials. Finally, the service was set up and accessed smoothly.

Here we will summarize the two items for future use.

There are three methods to log on to FTP: Anonymous logon, local logon, and virtual logon.

Anonymous logon: use the default user name when logging on to FTP, usually ftp or anonymous.

Local user logon: use a system user to log on to/etc/passwd.
Virtual user logon: this is an FTP private user. There are two methods to achieve virtual users, local data files and database servers.
The FTP virtual user is a private user of the FTP server. when a virtual user logs on to FTP, he can only access the resources provided by the FTP server, greatly enhancing the system security.
First, set up the server: 1. check whether the vsftpd driver is correctly installed with rpm-qa | grep vsftpd2. check whether the PAM-devel *** is installed *******. rpmrpm-qa | grep pam * rpm-ivh pam-devel *******. rpm local user logon

Start vsftpd in linux.

Service vsftpd start

Virtual User login 1. add the virtual user password file [root @ CentOS5/] # vi/etc/vsftpd/vftpuser.txt
Add the virtual user name and password, one line of user name, one line of password, and so on. An odd behavior username and an even behavior password.
Bobyuan # User name
123456 # Password
Markwang # User name
123456 # Password 2. generate a virtual user password authentication file
Convert the vftpuser.txt virtual user password file to a password authentication file recognized by the system.
First check whether the system has installed the software db4-utils required to generate the password authentication file.
[Root @ CentOS5/] # rpm-qa | grep db4-utils
[Root @ CentOS5/] # rpm-ivh db4-utils-4.3.29-9.fc6.i386.rpm
The following uses the db_load command to generate a virtual user password authentication file.
[Root @ CentOS5/] # db_load-T-t hash-f/etc/vsftpd/vftpuser.txt/etc/vsftpd/vftpuser. db3. edit the PAM authentication file of vsftpd
In the/etc/pam. d Directory,
[Root @ CentOS5/] # vi/etc/pam. d/vsftpd
Comment out all the other ones and add the following two lines:
Auth required/lib/security/pam_userdb.so db =/etc/vsftpd/vftpuser
Account required/lib/security/pam_userdb.so db =/etc/vsftpd/vftpuser4. create a local ing user and set the local directory permissions
All FTP virtual users need one system user, which does not need a password.
[Root @ CentOS5/] # useradd-d/home/vftpsite-s/sbin/nologin vftpuser
[Root @ CentOS5/] # chmod 700/home/vftpsite5. configure vsftpd. conf (set Virtual User configuration items)
[Root @ CentOS5/] # vi/etc/vsftpd. conf
Guest_enable = YES # enable a Virtual User
Guest_username = vftpuser # system user corresponding to the FTP Virtual User
Pam_service_name = vsftpd # PAM authentication file virtual_use_local_privs = YESuser_config_dir =/etc/vsftpd/vconf
6. configure the permission file/home/vftpsite/bobyuan for the Virtual User: Do not forget to set the permission for the virtual user logon Directory (the file is root user creation virtual user has no write permission) chown-R vftpuser. vftpuser/home/vftpsite/bobyuan/etc/vsftpd/vconf creates a permission file for each user. the file must be the same as the virtual user name. example: File name: bobyuanlocal_root =/home/vftpsite/bobyuanlocal_umask = timeout = 600data_connection_timeout = 120max_client = 10max_per_ip = 5local_max_rate = 50000pam_service_name = vsftpd 7. restart vsftpd
[Root @ CentOS5/] # service vsftpd restart
 
8. test Virtual User login to FTP
C: \ User \ Administrator> ftp 192.168.120.240
Connect to 192.168.120.240.
220 Welcome to bob ftp server
User (192.168.120.240 (none): markwang
331 Please specify the password.
Password:
230 Login successful.

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.