CentOS7.0 installation and configuration vsftp (YUM)

Source: Internet
Author: User
CentOS7.0 is used for configuration, which is similar to other versions. it is just a record here, at the same time, I can share it with anyone who needs it. 1. configure the firewall and enable the firewall required for Port 7.0. I changed it to iptables as the firewall (1) disable firewall: systemctlstopfirewalld. service # Stop fi

CentOS7.0 is used for configuration, which is similar to other versions. it is only used to make a record for you to view and share it with anyone who needs it.

1. configure the firewall and enable the required ports

7.0 the firewall used is firewall. I changed it to iptables as the firewall.

(1) disable firewall:

Systemctl stop firewalld. service

# Stop firewall

Systemctl disable firewalld. service

# Disable firewall startup

(2) install iptables firewall

Yum install iptables-services

# Installation

Vi/etc/sysconfig/iptables

# Edit the firewall configuration file

# Firewall configuration written by system-config-firewall

# Manual customization of this file is not recommended.

* Filter

: Input accept [0: 0]

: Forward accept [0: 0]

: Output accept [0: 0]

-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT

-A input-p icmp-j ACCEPT

-A input-I lo-j ACCEPT

-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT

-A input-m state -- state NEW-m tcp-p tcp -- dport 21-j ACCEPT

-A input-m state -- state NEW-m tcp-p tcp -- dport 10060: 10090-j ACCEPT

-A input-j REJECT -- reject-with icmp-host-prohibited

-A forward-j REJECT -- reject-with icmp-host-prohibited

COMMIT

: Wq!

# Save and exit

Systemctl restart iptables. service

# Restart the firewall to make the configuration take effect.

Systemctl enable iptables. service

# Set firewall startup

Note: Port 21 is the ftp service port, and Port 10060 to Port 10090 is the port required in Vsftpd passive mode. you can customize a tcp port greater than 1024.

2. disable selinux

Vi/etc/selinux/config

# SELINUX = enforcing

# Comment out

# SELINUXTYPE = targeted

# Comment out

SELINUX = disabled

# Add

: Wq! # Save and exit

Setenforce 0 # Make the configuration take effect immediately

3. install vsftp

Yum install-y vsftpd

# Install vsftpd

Yum install-y psmisc net-tools systemd-devel libdb-devel perl-DBI

# Install vsftpd Virtual User configuration dependency package

Systemctl start vsftpd. service

# Start

Systemctl enable vsftpd. service

# Set vsftpd startup

4. configure vsftp

Cp/etc/vsftpd. conf/etc/vsftpd. conf-bak

# Backing up default configuration files

Run the following command to set

Sed-I "s/anonymous_enable = YES/anonymous_enable = NO/g" '/etc/vsftpd. Conf'

Sed-I "s/# anon_upload_enable = YES/anon_upload_enable = NO/g" '/etc/vsftpd. Conf'

Sed-I "s/# anon_mkdir_write_enable = YES/g" '/etc/vsftpd. Conf'

Sed-I "s/# chown_uploads = YES/chown_uploads = NO/g" '/etc/vsftpd. Conf'

Sed-I "s/# async_abor_enable = YES/g" '/etc/vsftpd. Conf'

Sed-I "s/# ascii_upload_enable = YES/g" '/etc/vsftpd. Conf'

Sed-I "s/# ascii_download_enable = YES/g" '/etc/vsftpd. Conf'

Sed-I "s/# ftpd_banner = Welcome to blah FTP service./ftpd_banner = Welcome to FTP service./g" '/etc/vsftpd. Conf'

Echo-e "use_localtime = YES \ nlisten_port = 21 \ nchroot_local_user = YES \ nidle_session_timeout = 300

\ Ndata_connection_timeout = 1 \ nguest_enable = YES \ nguest_username = vsftpd

\ Nuser_config_dir =/etc/vsftpd/vconf \ restart rtual_use_local_privs = YES

\ Npasv_min_port = 10060 \ npasv_max_port = 10090

\ Naccept_timeout = 5 \ nconnect_timeout = 1 ">/etc/vsftpd. conf

5. create a virtual user file

Touch/etc/vsftpd/virtusers

Edit The Virtual User Name Single File: (the first line of the account, the second line of the password, note: Do not use root as the user name, the system retains)

Vi/etc/vsftpd/virtusers

Web1

123456

Web2

123456

Web3

123456

: Wq!

# Save and exit

6. generate virtual user data files

Db_load-T-t hash-f/etc/vsftpd/virtusers. db

Chmod 600/etc/vsftpd/virtusers. db

# Set the PAM authentication file and specify to read the virtual user database file

7. add the following information to the header of the/etc/pam. d/vsftpd File (it is invalid to add the following information)

Back up cp/etc/pam. d/vsftpd/etc/pam. d/vsftpdbak before modification

Vi/etc/pam. d/vsftpd

Auth sufficient/lib64/security/pam_userdb.so db =/etc/vsftpd/virtusers

Account sufficient/lib64/security/pam_userdb.so db =/etc/vsftpd/virtusers

Note: If the system is 32-bit, the above is changed to lib; otherwise, the configuration fails.

8. create a system user vsftpd. the user directory is/home/wwwroot, and the user logon terminal is set to/bin/false (even if the user cannot log on to the system)

Useradd vsftpd-d/home/wwwroot-s/bin/false

Chown vsftpd: vsftpd/home/wwwroot-R

Chown www: www/home/wwwroot-R

# If the virtual user's host user is www, you need to set it like this.

9. create a configuration file for the virtual user's personal Vsftp

Mkdir/etc/vsftpd/vconf

Cd/etc/vsftpd/vconf

Touch web1 web2 web3

# Create three Virtual User configuration files

Mkdir-p/home/wwwroot/web1/http/

Vi web1

# Edit the user's web1 configuration file. Others are similar to this configuration file.

Local_root =/home/wwwroot/web1/http/

Write_enable = YES

Anon_world_readable_only = NO

Anon_upload_enable = YES

Anon_mkdir_write_enable = YES

Anon_other_write_enable = YES

10. restart the vsftpd server.

Systemctl restart vsftpd. service

Note:

Guest_username = vsftpd # specify the host user of the virtual user (that is, the user we created earlier)

Guest_username = www

# If the ftp directory is directed to the root directory of the website for uploading website programs, you can specify the host user of the virtual user as the nginx running account www, which can avoid many permission settings problems

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.