Install and configure vsftp in RHEL/centos

Source: Internet
Author: User


Note: This article is from the blog "afei". If you want to repost this article, please contact the author! And indicate the source: http://blog.csdn.net/faye0412/archive/2011/03/26/6280750.aspx

Generally, after installing the system, we will automatically install the vsftp service, but sometimes we still have to do it by ourselves. For example, we have configured it for my friend these two days, you can easily record the process so that you can check the process or provide convenience to your friends when you need it :)

1. InstallUse chkconfig -- list to check whether the vsftpd service is installed. Run the yum command to install: Yum-y install vsftpd and create a log file for it: Touch/var/log/vsftpd. log completes vsftp installation by using two simple commands, but if you want to access the ftp: // your_ip address like this, it will not work. Why ?? It's easy. Permission issues! 2. Start and configure auto-startUse chkconfig -- list to view the vsftpd service startup items. If you see the following results: vsftpd 0: off 1: off 2: off 3: off 4: off 5: off 6: The off service is all off. Note that off indicates whether the service will be started automatically when the server is started. We will use the following command to configure its own startup: chkconfig -- level 2345 vsftpd on #2345 corresponds to the above 0-6 items. View and manage the FTP service: Start the FTP service: Service vsftpd start to view the FTP service status: service vsftpd status restart FTP service: Service vsftpd restart disable FTP service: Service vsftpd stop 3. Configure the vsftp ServiceEdit the/etc/vsftpd. conf file and configure the vsftp service: # vi/etc/vsftpd. conf 3.1 Edit and modify the following items:Anonymous_enable = No # Set not to allow anonymous access to local_enable = yes # Set that the local user can access. Note: If a virtual host user is used, all virtual users cannot access the project if the project is set to No. Chroot_list_enable = yes # the user cannot leave the main directory xferlog_file =/var/log/vsftpd. log # set the path for saving vsftpd service logs. Note: This file does not exist by default. You must manually touch ascii_upload_enable = yes # Allow uploading in ASCII mode ascii_download_enable = yes # Set to support the upload and download functions in ASCII mode. Pam_service_name = vsftpd # PAM Authentication file name. Pam will be authenticated according to/etc/PAM. d/vsftpd
The following are important centos FTP service configuration items for vsftpd virtual user support. By default, vsftpd. conf does not contain these configuration items. You must manually add the RHEL/centos FTP service configuration. Guest_enable = yes # enable the virtual user function. Guest_username = FTP # specifies the host user of the virtual user. -In RHEL/centos, the built-in FTP user user_config_dir =/etc/vsftpd/vuser_conf # sets the path for storing the RHEL/centos FTP service file of the virtual user's personal vsftp. Centos FTP service file that stores virtual user personality (configuration file name = virtual user name)
3.2 Create a chroot list and add FTP users to it:Touch/etc/vsftpd/chroot_listecho ftp>/etc/vsftpd/chroot_list
3.3 perform authentication:First, install the Berkeley dB tool. Many people cannot find db_load. The problem is that this package is not installed. Yum install db4 db4-utils then, create the User Password text/etc/vsftpd/vuser_passwd.txt, note that the odd line is the user name, even the line is the password ftpuser1ftppass1ftpuser2ftppass2 followed ,. generate the database file db_load-T-t hash-F/etc/vsftpd/vuser_passwd.txt/etc/vsftpd/vuser_passwd.db for virtual user authentication, and then edit the authentication file/etc/PAM. d/vsftpd, comment out all the original statements and add the following two statements auth required pam_userdb.so DB =/etc/vsftpd/vuser_passwdaccount required pam_userdb.so DB =/etc/vsftpd/vuser_passwd, create the RHEL/centos FTP service file mkdir/etc/vsftpd/vuser_conf/VI/etc/vsftpd/vuser_conf/ftpuser1 as follows: local_root =/opt/var/ftp1 virtual user's root directory (based on actual modification) write_enable = Yes writable anon_umask = 022 mask anon_world_readable_only = No anon_upload_enable = Yes enabled = Enabled = Yes 4. Attach permissions to the directory and restart the vsftp service:Mkdir/opt/var/FTP/ftpuser1chmod 777/opt/var/FTP/ftpuser1service vsftpd restart 5. FAQs: 5.1 553 cocould not create FileThis is generally a problem with SELinux. Set a value for SELinux and restart the server. Setsebool-P ftpd_disable_trans 1 service vsftpd restart 5.2 500 Oops: Bad bool value in config file for: write_enableNote that there is no space at the end of each line in your centos FTP service file. Generally, an error is caused by extra spaces. 5.3 after a virtual user uploads an object, the default permission is 600, and the user cannot download the object.Add or modify the value of anon_umask in the configuration file. For example, anon_umask = 022 or 000 6. Use commands to add FTP users (similar to 3.3) 6.1 add an FTP user. Command Format:# Adduser-D/directory path-g ftp-S/sbin/nologin Username: # adduser-D/opt/dongge-g ftp-S/sbin/nologin dongge adds a user named dongge whose directory belongs to the FTP user group under/opt/dongge. This user cannot log on to our terminal server. 6.2 Add a password:# Permissions that can be read and written by a passwd dongge user set to ftpuser in the directory # chown-r dongge: ftp/opt/dongge/ 6.3 directory mounting:If we want to mount the/opt/dongge directory to our FTP directory, you can use the mount command # Mount -- bind/opt/dongge/var/FTP/dongge to complete the configuration of Adding users and attaching directories. 7. Support for HTTP downloadEdit/etc/httpd/CONF/httpd. CONF file: # vi/etc/httpd/CONF/httpd. add the following code to the conf file: alias/fileshare "/var/FTP/ftpuser1" <directory "/var/FTP/ftpuser1"> options indexes Multiviews AllowOverride none order allow, deny allow from all </directory> to restart the HTTPd service, you can use http: // your_ip/fileshare to access and download the required files :) 8. Lazy vsftp configuration methodAfter completing steps 1, 2, 3.1, add the following code directly to/etc/vsftpd. in the conf file: write_enable = Yes writable anon_umask = 022 mask anon_world_readable_only = No anon_upload_enable = Yes anon_mkdir_write_enable = yesanon_other_write_enable = Yes
Restart the vsftpd service can be :) simple, heheh this article Sina Blog address: http://blog.sina.com.cn/s/blog_49fd52cf0100nek9.html

 

Related Article

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.