CentOS 7 Operations Management Note (4)----Install the FTP server

Source: Internet
Author: User

Installing the FTP server under CentOS 7 allows hosts in the LAN to have a site to share files with.

Under the Linux system, VSFTP is a widely used FTP software, its features are small and light, safe and easy to use. At present, in the open-source operating system commonly used FTP software, in addition to vsftp, mainly proftpd, pureftpd and wu-ftpd and so on. This essay records the installation and configuration of VSFTP.

Note: All operations in this essay are performed in the CentOS7 installed in the VMware Workstations virtual machine, it is best to set the snapshot before the operation, so that a step error can also be returned to the original state:

1. Install Vsftp: Under root user, enter:

Yum Install -y vsftpd

To view the installation situation:

2. Anonymous FTP configuration:

Allow anonymous users to access and upload files, the configuration file path is generally/etc/vsftpd.conf, if the use of RPM package installation, the configuration file is located in/etc/vsftpd/vsftpd.conf

(i) After installing VSFTPD, the software will automatically generate the/var/ftp/pub directory in the/var directory, which is the default access directory for anonymous users. Because snapshots are taken in a virtual machine, you can verify that the/VAR/FTP directory was generated for VSFTPD software by going to the snapshot before installing VSFPTD. The snapshot state before the virtual machine is brokered to the VSFTPD software installation. Input

ls /var/ftp

The directory is not displayed.

Then go to the snapshot after installing VSFTPD, enter the same command again, the result is as follows:

Displays the pub folder under this directory, which is currently empty; This is sufficient to indicate that the/var/ftp/and/var/ftp/pub folders are automatically generated for the VSFTPD software installation process.

(ii) There are currently FTP user groups and FTP users in the system, and the blogger has been authenticated by a rollback of the snapshot, and the user and the user group are not generated by the VSFTPD software. The commands used are:

groups FTP

In two snapshot states, the FTP user belongs to the FTP user group.

Give the user FTP permissions to the default directory so that files can be uploaded.

This command means that all users in the FTP user group are set to the owner of the/var/ftp/pub directory, and the meaning of the-R parameter is to use the recursive method, that is, all other subdirectories under the pub directory are also owned by all users in the FTP user group.

(iii) Use

Vim/etc/vsftpd/vsftpd.conf

command to edit the VSFTPD configuration file.

The configuration is as follows:

which

grep -v ^# filename

A command is a valid content that is viewed in the filename file to remove the commented out contents of ' # '.

For a detailed explanation of options such as Chroot_local_user in the red box, see: http://blog.csdn.net/bluishglc/article/details/42398811

(3) Start the FTP server

(i) Check the port status before starting VSFTPD:

Netstat-nptl

You can see that there are currently only IPv4 53,22,631 ports and IPv6 port 22nd is listen.

Input

Systemctl Start VSFTPD

Start the VSFTPD service.

Enter the command again

You can see that Port 21st is started, which is the command port for FTP. (The FTP data port is 20).

(ii) Use the FTP service on another Ubuntu connection CentOS7 that is turned on in the virtual machine:

The display cannot be connected because Port 21st is not turned on on the server's firewall.

Then edit the iptables on the CENTOS7 server:

Vim/etc/sysconfig/iptables

Add two lines in the red box to open ports 20 and 21st. (Port 21st is an FTP command port, Port 20th is an FTP data port)

Before installing iptables, the following commands have been used

Systemctl Disable FIREWALLD  #禁止开机启动 firewalldsystemctl stop firewalld      #停止运行firewalldsystemctl enable iptables    #开机启动iptablessystemctl start iptables        #启动iptables

Currently, FIREWALLD is not started, Iptables is running and should be restarted if/etc/sysconfig/iptables files are modified iptables

Systemctl Restart Iptables

then enter

Systemctl Stop VSFTPD
Netstat-nptl

Port 21st is not turned on because the VSFTPD server has been shut down:

Start the VSFTPD server and view the ports:

Systemctl Start VSFTPD
Netstat-nptl

The VSFTPD service is reopened and Port 21st is listening. The above phenomenon indicates whether the port listens or not is only related to the service running or not, it has nothing to do with the open port in firewall iptables.

(iii) using Ubuntu to connect to the FTP service on CentOS 7:

Connection Successful!

4. Uploading and downloading files using FTP

(i) Enter the LS command on the connected FTP command line:

Displays the pub folder under the current directory, which indicates that the directory where the current anonymous user is logged on by default is the/var/ftp directory on the CentOS7 server.

(ii) Uploading files:

Use

CD Pub

command to enter the pub folder

and then use

Put Filename.txt

command to upload a local filename.txt file

( Note: Because Ubuntu is in the same directory as/home/username before landing FTP, filename.txt defaults to/home/username/filename.txt on Ubuntu, and you can specify files with absolute paths.) The current directory of the client can be changed with the LCD pathname command )

Results:

Displays "533 Could not create file."

Use the following command on CentOS7 to change the permissions of the/var/ftp/pub folder:

chmod 766 /var/ftp/pub

Restart the VSFTPD service, connect to the Ubuntu client, and then upload the file, and the result is "533 Could not create file."

Online search reasons, according to the instructions on this page: http://www.111cn.net/sys/linux/45542.htm on the CentOS7 server to do the following settings:

Restart the VSFTPD service on the CENTOS7 server, and then re-login to the server on Ubuntu, this is the default login into the/var/ftp directory, be sure to use the CD Pub command to convert into the pub directory, and then try to upload files:

Success!

(iii) Download the file:

On the CENTOS7 server, use the

vim/var/FTP/pub/welcom.txt

command to create a new file.

Try the download on Ubuntu:

Success!

CentOS 7 Operations Management Note (4)----Install the FTP server

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.