How to build an ftp server on centos 7 and set up ftp on centos 7

Source: Internet
Author: User
Tags default ftp port

How to build an ftp server on centos 7 and set up ftp on centos 7

Test Environment

1. CentOS7

2. Test the Server IP address 111.230.247.206

1. Install and start the FTP service

1.1 install VSFTPD

Install vsftpd using yum

Yum install-y vsftpd

1.2 start VSFTPD

After the installation is complete, start the FTP service:

Service vsftpd start

After starting, you can see that the system has listened on port 21:

Netstat-nltp | grep 21

Access ftp: // 111.230.247.206 to view the/var/ftp directory on the machine.

2. Configure FTP Permissions

2.1 understand VSFTP Configuration

The vsftpd configuration directory is/etc/vsftpd, which contains the following configuration files:

Vsftpd. conf is the main configuration file ftpusers. Configure user_list to prohibit access to the FTP server. Configure user access control.

2.2 block anonymous access and switch the root directory

Both anonymous access and root directory switching pose security risks to the server. We disable these two functions.

Edit/etc/vsftpd. conf, find the following two configurations and modify them:

# Disable anonymous users from 12 YES to NO

Anonymous_enable = NO

# Do not switch to the root directory and Delete row 101 #

Chroot_local_user = YES

After editing, save the configuration and restart the FTP service.

Service vsftpd restart

2.3 create an FTP user

Create a user ftpuser

Useradd ftpuser

Set password for user ftpuser

Echo "mima" | passwd ftpuser -- stdin

2.4 restrict access by this user through FTP only

Restrict the ftpuser to access the server only through FTP, but not directly log on to the server:

Usermod-s/sbin/nologin ftpuser

2.5 assign a home directory to the user

Create a home directory for the user ftpuser and agree:

/Data/ftp is the main directory, which cannot upload files

/Data/ftp/pub files can only be uploaded to this directory

Create related directories in/data

Mkdir-p/data/ftp/pub

2.5.1 create a login welcome File

Echo "Welcome to use FTP service.">/data/ftp/welcome.txt

Set Access Permissions

Chmod a-w/data/ftp & chmod 777-R/data/ftp/pub

Set as the user's home directory:

Usermod-d/data/ftp ftpuser

3. access FTP

Select a method to access the established FTP service based on your personal work environment.

Note: Disable the firewall or open the default FTP port (21)

# Disable the SELinux Service

Setenforce 0

# Disable the Firewall

Iptables-F

Access through Windows Resource Manager

Windows users can copy the following link

Access the address bar of the Resource Manager:

Ftp: // ftpuser: mima@111.230.247.206

Here, ftpuser is the username used to log on to FTP, and mima is the password used to log on to FTP.

Access through FTP client tools

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.