Centos6 install ftp server

Source: Internet
Author: User

Centos6 install ftp server

Vsftpd Detection: You can run the following command to check whether the installation is successful:
[Root @ localhost ~] # Rpm-qa | grep vsftpd

1. Check whether the service is installed

Use chkconfig-list to check whether the vsftpd service has been installed,
If the installation is complete, it can be found in the list. If not, it will be completely installed.
Run the yum command to install: yum-y install vsftpd.
Create a log file for it: touch/var/log/vsftpd. log

2. Configure auto-start

View the startup configuration:
Chkconfig-list
By default, all are off.
Vsftpd 0: off 1: off 2: off 3: off 4: off 5: off 6: off.
Set the startup configuration: chkconfig-level 2345 vsftpd on
Run the command and run the following command in chkconfig-list:
Vsftpd 0: off 1: off 2: on 3: on 4: on 5: on 6: off.
Install and configure vsftpd in CentOS
View and manage ftp services:
Start ftp service: service vsftpd start
View ftp service status: service vsftpd status
Restart the ftp service: service vsftpd restart
Disable ftp service: service vsftpd stop
The above command can be used to try each input and then turn it off after one lap.
In this step, the vsftpd installation and Automatic startup settings have been completed, but cannot be connected now. You also need to modify its configuration file to create an ftp virtual user.

3. install and configure vsftpd in CentOS-basic configuration

Modify the vsftpd. conf configuration file:
Configure vsftp service: vi/etc/vsftpd. conf
Mainly modify these projects
Anonymous_enable = NO # Set that anonymous access is not allowed
Local_enable = YES # Set the local user to 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 # prevents the user from leaving the main directory
Xferlog_file =/var/log/vsftpd. log # sets the path for saving service logs of vsftpd. Note: This file does not exist by default. Must be manually touch
Ascii_upload_enable = YES # Allow upload in ASCII mode
Ascii_download_enable = YES # sets the support for uploading and downloading in ASCII mode.
Pam_service_name = vsftpd # PAM Authentication file name. PAM will be authenticated according to/etc/pam. d/vsftpd
By default, vsftpd. conf does not contain the following configuration items. You need to manually add them to the end of the configuration file.
Guest_enable = YES # enable the virtual user function.
Guest_username = ftp # specifies the host user of the virtual user. There are already built-in ftp users in centos (Note: This user is specified in the chroot_list_file =/etc/vsftpd/chroot_list file) -RHEL/CentOS already has built-in ftp users.
User_config_dir =/etc/vsftpd/vuser_conf # set 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)
Install and configure vsftpd in CentOS
Create a chroot list and add ftp users to it:
Touch/etc/vsftpd/chroot_list
Echo ftp>/etc/vsftpd/chroot_list # specifies the host user of the virtual user

4. install and configure vsftpd in CentOS-user login information configuration

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 or yum install db4 * (* Indicates installing all installation Packages containing db4 characters)
Then, create the User Password text/etc/vsftpd/vuser_passwd.txt. Note that the odd line is the user name, and the even line is the password.
Ftpuser1
Ftppass1
Ftpuser2
Ftppass2
Then, generate the database file for virtual user authentication
Db_load-T-t hash-f/etc/vsftpd/vuser_passwd.txt/etc/vsftpd/vuser_passwd.db
Edit the authentication file/etc/pam. d/vsftpd, open the file, comment out all the original content with "#", and add two lines.
The 32-bit System adds the following two sentences: auth required pam_userdb.so db =/etc/vsftpd/vuser_passwd
Account required pam_userdb.so db =/etc/vsftpd/vuser_passwd
The 64-bit System adds the following two sentences: auth required/lib64/security/pam_userdb.so db =/etc/vsftpd/vuser_passwd
Account required/lib64/security/pam_userdb.sodb =/etc/vsftpd/vuser_passwd
Finally, create a virtual user personalized service file
Mkdir/etc/vsftpd/vuser_conf/
Vi/etc/vsftpd/vuser_conf/ftpuser1
The content is as follows:
Local_root =/opt/var/ftp/ftpuser1 # virtual user root directory (based on actual modification)
Write_enable = YES # writable
Anon_umask = 022 # mask
Anon_world_readable_only = NO
Anon_upload_enable = YES
Anon_mkdir_write_enable = YES
Anon_other_write_enable = YES
Install and configure vsftpd in CentOS
Install and configure vsftpd in CentOS
Install and configure vsftpd in CentOS
Install and configure vsftpd in CentOS
Attach permissions to the directory and restart the vsftp service:
Mkdir/opt/var/ftp/ftpuser1
Chmod 777/opt/var/ftp/ftpuser1
Service vsftpd restart
In this way, all the configurations are complete. You can use the ftp tool to log on and try:
Account: ftpuser1 password: ftppass1; port: 21 by default, IP address server address.

FAQs:

In actual operations, after the above steps, the access is not normal !! You also need to pay attention to two issues.
Firewall: If the firewall is not configured and you use ftp to connect, you will find that the connection times out. In this case, you can directly disable the Firewall/etc/init. d/iptables stop or open the corresponding port in a simple and violent way.
/Sbin/iptables-I INPUT-p tcp-dport 21-j ACCEPT
/Etc/rc. d/init. d/iptables save.
In this way, you have passed the first level.
SELinux: After configuring the firewall, you should be able to successfully connect to ftp. The directory is empty at this time. You can create a file or upload a file, and an error will be reported. In this case, you can temporarily disable SELinux: setenforce 0 (without restarting the machine.
After the above settings, all ftp functions should be available.
If the following error occurs:
500 OOPS: bad bool value in config file for: write_enable
Check whether there are spaces or other unnecessary content behind each line in your configuration file.

Service vsftpd start command

Service vsftpd restart

Service vsftpd stop

Directly disable the Firewall/etc/init. d/iptables stop or open the corresponding port/sbin/iptables-I INPUT-p tcp-dport 21-j ACCEPT/etc/rc. d/init. d/iptables save

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.