The basics of vsftp installation and configuration in CentOS

  

1. Install using chkconfig --list to see if the vsftpd service is installed; use the yum command to install directly: yum -y install vsftpd and then create a log file for it: touch /var/Log/vsftpd.log

This simple two command completes the installation of vsftp, but if you want to access ftp://your_ip now, it will not work, you need to configure permissions!

2. Startup and configuration self-startup Use chkconfig --list to view the vsftpd service startup items; if you see the following result: vsftpd 0:off 1:off 2:off 3:off 4 :off 5:off 6:off The services are all off. Note that the off here indicates whether the server will start the service when the server starts. We use the following command to configure its self-starting: chkconfig --level 2345 vsftpd on # 2345 corresponds to the corresponding 0-6 items

View and manage ftp service: Start ftp service: service vsftpd start View ftp service status: service vsftpd status Restart ftp service: service vsftpd restart Close ftp service: service Vsftpd stop

3. Configure the vsftp service to edit the /etc/vsftpd/vsftpd.conf file and configure the vsftp service: #vi /etc/vsftpd/vsftpd.conf 3.1 Edit and modify the following items: anonymous_enable=NO #Set Do not allow anonymous access to local_enable=YES #Set local users to access. Note: If you use a virtual host user, all virtual users will not be accessible if the project is set to NO. Chroot_list_enable=YES # Make the user unable to leave the home directory xferlog_file=/var/log/vsftpd.log #Set the service log save path for vsftpd. Note that this file does not exist by default. Must be manually touched out ascii_upload_enable=YES #Allow upload using ASCII mode ascii_download_enable=YES #Set support for ASCII mode upload and download functions. 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. The default vsftpd.conf does not include these settings, you need to manually add the RHEL/CentOS FTP service configuration. Guest_enable=YES #Set the enable virtual user feature. Guest_username=ftp #Specify the host user of the virtual user. -RHEL/CentOS already has a built-in ftp user user_config_dir=/etc/vsftpd/vuser_conf #Set the virtual user's personal vsftp RHEL/CentOS FTP service file storage path. CentOS FTP service file (configuration file name = virtual user name) for storing the virtual user's personality 3.2 Create a chroot list and add the ftp user to it: touch /etc/vsftpd/chroot_list echo ftp >> /etc/vsftpd/chroot_list

3.3 Certification: First, the Berkeley DB tool is installed. Many people can't find the problem with db_load or not. Yum install db4 db4-utils Then, create the user password text /etc/vsftpd/vuser_passwd.txt, note that the odd line is the username, even the password is ftpuser1 ftppass1 ftpuser2 ftppass2 Next, generate the virtual user authentication db file db_load -T -t Hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db Subsequently, edit the authentication file /etc/pam.d/vsftpd, comment out the original statement and add the following two sentences auth required pam_userdb.so db= /etc/vsftpd/vuser_passwd account required pam_userdb.so db=/etc/vsftpd/vuser_passwd Finally, create a virtual user personality RHEL/CentOS FTP service file mkdir /etc/vsftpd/vuser_conf/vi /etc/vsftpd/vuser_conf/ftpuser1 : local_root=/opt/var/ftp1 The root directory of the virtual user (as per the actual modification) write_enable=YES can write anon_umask=022 mask anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES

4. Directory with permissions and restart the vsftp service: mkdir /opt/var/ftp/ftpuser1 chmod 777 /opt/var/ftp/ftpuser1 service vsftpd r Estart

5. Frequently Asked Questions: 5.1 553 Could not create file Generally, it is 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_enable Note that your CentOS FTP service file guarantees that there are no spaces at the end of each line. Generally, errors are in extra spaces. on.

5.3 After the virtual user uploads, the default permission is: 600, the user cannot download the file. Add or modify the value of the anon_umask item in the configuration file. Such as anon_umask=022 or 000

6. Use the command to add ftp user (similar to 3.3) 6.1 Add ftp user, command format: #adduser -d /directory path -g ftp -s /sbin/nologin username If used: #adduser -d /opt/dongge -g ftp -s /sbin/nologin dongge Added a user named dongge whose directory belongs to /opt/dongge and belongs to the ftp user group. This user is not allowed to log in to our terminal server.

6.2 Add password: #passwd dongge Set the user name FTPUSER to read and write permissions in the directory #chown -R dongge:ftp /opt/dongge/

6.3 Directory Mount : If we want to hang the /opt/dongge directory under our ftp directory, you can use the mount command #mount –-bind /opt/dongge /var/ftp/dongge so that we have added the user and mount directory. Configuration.

7. Support http download editing /etc/httpd/conf/httpd.conf file: #vi /etc/httpd/conf/httpd.conf

Add the following code: Alias ​​/fileshare " ;/var/ftp/ftpuser1" <Directory "/var/ftp/ftpuser1"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory>

Restart the httpd service, ie You can use http://your_ip/fileshare to access and download the required files:)

8. How to configure lazy vsftp After completing steps 1, 2, 3.1, add the following code directly to /etc/vsftpd In the /vsftpd.conf file: write_enable=YES can be written

Copyright © Windows knowledge All Rights Reserved