Install the FTP server on CentOS7 to save images uploaded by the service side.

Source: Internet
Author: User
Tags ftp protocol

1, CentOS unloading vsftpd method

If the VSFTPD service is already installed on the server, the configuration error requires uninstalling the VSFTPD service.

1.1 Find VSFTPD Services
[[email protected]/] # Rpm-aq vsftpd 

Return results display:

# Here is the return result of finding vsftpd

Indicates that the VSFTPD service has been installed before this service period.

1.2 Delete the Found VSFTPD service

Note: Stop the vsftpd before uninstalling the VSFTPD

[[email protected]/] # /sbin/service vsftpd Stop 

Uninstall VSFTPD:

[[email protected]/] # rpm-e vsftpd-3.0.2-21.el7.x86_64 

Return results display:

# The VSFTP user list file will be backed up when deleted
1.3 Enter the verification command to verify that the VSFTPD service has been deleted
[[email protected]/] # /sbin/service vsftpd stopredirecting to/bin/systemctl stop  # no vsftpd found    
[[email protected]/] # /sbin/service vsftpd startredirecting to/bin/systemctl start  # no vsftpd found   

If entering the above two commands shows that the VSFTPD service cannot be found, it proves that the uninstallation was successful.

2. Installing VSFTPD Components
[[email protected]/] # yum-y install vsftpd 
2.1 Starting FTP
[[email protected] home] # systemctl start Vsftpd.service 
2.2 Release 21 ports
[[email protected]/] # Firewall-cmd--zone=public--add-port=21/tcp--permanent[[email protected]/]# Firewall-cmd--reload 
3. Detailed configuration of the VSFTPD service 3.1 turn off anonymous users
[[email protected] vsftpd] # vim/etc/vsftpd/vsftpd.conf 

Modify the following three entries in the vsftpd.conf configuration file:

anonymous_enable=NO#anon_upload_enable=yes#anon_mkdir_write_enable=yes   

Then restart the FTP service:

[[email protected] vsftpd] # systemctl restart  vsftpd.service 

After you configure the restart, anonymous users cannot log on.

3.2 Setting up an FTP virtual hosting account

Create a new user who cannot log on to the system. Used only to log in to the FTP service, where the user directory is not set. The default is under home:

[[email protected] vsftpd] # Useradd ftpuser-s/sbin/nologin 

To set a password for a ftpuser user:

[[email protected]/] # passwd ftpuser 
3.3 Viewing the status of FTP
[[email protected]/] # getsebool-a|grep ftp 

Show Results:

Ftpd_anon_write--offftpd_connect_all_unreserved---  offftpd_connect_db  --and-- Offftpd_use_cifs--offftpd_use_fusefs--Offftpd_use_nfs--   Offftpd_use_passive_mode OFFHTTPD_CAN_CONNECT_FTP--Offhttpd_enable_ftp_server--  offtftp_anon_write-  off - off            

Set the red two states above to on:

[[email protected] vsftpd] # Setsebool-p allow_ftpd_full_access on[[email protected] vsftpd]# setsebool-p tftp_home_diron 
       
3.4 Configuring Vsftpd.conf

Restrict system users from locking in the/home/ftpuser directory

If set to Chroot_local_user=yeschroot_list_enable=YES (this line can not, or can have) chroot_list_file=/etc/vsftpd.chroot_ List then, any user who is added to the file vsftpd.chroot_list is a user who is not subject to restriction and can browse the parent directory of its home directory. So, if you don't want a user to be able to browse the contents of their home directory ancestor directory, you can set the The user is then not added to the file Vsftpd.chroot_list (at which point the user in the file can browse to a directory other than its home directory). Or, set the following chroot_local_user=nochroot_list_enable= YES (this line must have, otherwise the file vsftpd.chroot_list will not work) chroot_list_file=/etc/vsftpd.chroot_ The list then adds all users who do not wish to have the permissions on the directories above their home directory to file Vsftpd.chroot_list (at which point the user in the file is not allowed to browse to a directory other than their home directory) (a single user name).   
[[email protected] vsftpd] # vim/etc/vsftpd/vsftpd.conf 

Here are two scenarios, I use the second one, configured as follows:

#(this line must have, otherwise the file vsftpd.chroot_list will not work) Chroot_list_file=/etc/vsftpd/chroot_list

The default chroot_list is not present

[[email protected] vsftpd] # Vim/etc/vsftpd/chroot_list 

Then join Ftpuser, indicating that only ftpuser cannot access the parent directory and restart VSFTPD.

3.5 Modify Permissions

Permission to modify/home/ftpuser is not writable

[[email protected] vsftpd] # chmod a-w/home/ftpuser/taotao 

This is because we have changed the permissions of the/home/ftpuser/taotao file to not writable, so we create a images folder in this directory to upload the file. and assign permissions to the Ftpuser user

[[email protected] Taotao] # mkdir images[[email protected] images]# chown ftpuser images   

4. Turn on PASV (passive mode)

Join at the bottom of the/etc/vsftpd/vsftpd.conf

pasv_enable=yespasv_min_port=30000pasv_max_port=30999 

and add it after the Userlist_enable=yes file

userlist_deny=nouserlist_file=/etc/vsftpd/user_list

To turn on the firewall:

[Email protected] taotao]# Firewall-cmd--reload

This allows you to upload files using an FTP server.

For more vsftpd related tutorials, see the following :

Linux CentOS 6.5 Build vsftpd FTP server http://www.linuxidc.com/Linux/2016-07/133319.htm

CentOS installation vsftpd-3.0.2 and Security Configuration http://www.linuxidc.com/Linux/2016-12/138040.htm

OpenSUSE 13.2/13.1 Under Install configure FTP server VSFTPD http://www.linuxidc.com/Linux/2014-12/110070.htm

CentOS7 VSFTPD http://www.linuxidc.com/Linux/2016-11/137150.htm based on virtual user

Ubuntu 14.04 Configuration vsftpd Implement FTP server-connect AWS Http://www.linuxidc.com/Linux/2016-08/133933.htm via FTP

FTP protocol details and VSFTPD installation configuration on Linux http://www.linuxidc.com/Linux/2016-09/134831.htm

CentOS 6.7 Installation VSFTPD Server http://www.linuxidc.com/Linux/2017-04/142612.htm

CentOS 7.3 Installation Configuration vsftpd file Server http://www.linuxidc.com/Linux/2017-06/144886.htm

Vsftpd3.0--ftp local user chapter of server Building http://www.linuxidc.com/Linux/2017-04/142699.htm

CentOS7 VSFTPD http://www.linuxidc.com/Linux/2016-11/137150.htm based on virtual user

Ubuntu 16.04 under VSFTPD installation configuration instance http://www.linuxidc.com/Linux/2017-06/144807.htm

This article permanently updates the link address : http://www.linuxidc.com/Linux/2017-08/146085.htm

Install the FTP server on CentOS7 to save images uploaded by the service side.

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.