Install the ftp service on centos7

Source: Internet
Author: User

Install the ftp service on centos7

Install and configure the FTP server in CentOS 7.

Suppose we have the following requirements:

Path permission remarks

/Ftp/open all staff, including guests, can access read-only

/Ftp/private only allow access by Alice, Jack, and Tom

Alice and Jack can only be downloaded,

Tom can upload all files using a virtual account

Install FTP

// Use yum for Installation

# Yum-yinstall ftp vsftpd

// Or use rpm to install the following two packages

Ftp-0.17-66.el7.x86_64

Vsftpd-3.0.2-9.el7.x86_64

// You need to install a db package to encrypt the account information of a virtual user.

// This package is installed in centos7 by default.

# Rpm-qf/usr/bin/db_load

Libdb-utils-5.3.21-17.el7_0.1.x86_64

Configuration

# Mkdir/ftp/open

Test files

# Echo opentest>/ftp/open/open.txt

# Echo filetest>/tmp/filetest1.txt

# Touch/ftp/open/anontest.txt

// View the path of the configuration file

# Rpm-qc vsftpd

/Etc/logrotate. d/vsftpd

/Etc/pam. d/vsftpd

/Etc/vsftpd/ftpusers

/Etc/vsftpd/user_list

/Etc/vsftpd. conf

# Cd/etc/vsftpd/

// Back up the original configuration file

# Cp vsftpd. conf vsftpd. conf. origin

// Create a plaintext Password File

# Vi/etc/vsftpd/vftpuser.txt

Alice

P @ ssw0rd

Jack

P @ ssw0rd

Tom

P @ ssw0rd

// Create a password DB File Based on plaintext

# Db_load-T-t hash-f/etc/vsftpd/vftpuser.txt \

/Etc/vsftpd/vftpuser. db

// View the password data file

# File/etc/vsftpd/vftpuser. db

/Etc/vsftpd/vftpuser. db: Berkeley DB (Hash, version9, native byte-order)

// Create a vftpd guest Account

# Useradd-d/ftp/private-s/sbin/nologin vftpuser

# Vi/etc/pam. d/vsftpd

Comment out all the configuration lines of auth and account and add the following content:

Auth required pam_userdb.so db =/etc/vsftpd/vftpuser

Account required pam_userdb.sodb =/etc/vsftpd/vftpuser

// Open the configuration file

# Vi/etc/vsftpd. conf

// Add at the end

Anon_root =/ftp/open

Virtual_use_local_privs = YES

Guest_enable = YES

Guest_username = vftpuser

Chroot_local_user = YES

Allow_writeable_chroot = YES

// Set Automatic Start

# Systemctl enable vsftpd

Ln-s '/usr/lib/systemd/system/vsftpd. service'/etc/systemd/system/multi-user.target.wants/vsftpd. Service'

# Systemctlstart vsftpd

// View the current status

# Systemctlstatus vsftpd

Vsftpd. service-Vsftpd ftp daemon

Loaded: loaded (/usr/lib/systemd/system/vsftpd. service; enabled)

Active: active (running) since Mon 2014-08-11 19:57:12 CST; 22 h ago

Main PID: 12733 (vsftpd)

CGroup:/system. slice/vsftpd. service

A "12733/usr/sbin/vsftpd/etc/vsftpd. conf

Systemd [1]: Starting Vsftpd ftp daemon...

Systemd [1]: Started Vsftpd ftp daemon.

Vsftpd [12738]: pam_userdb (vsftpd: auth): user 'Alice 'granted access

Vsftpd [12753]: pam_userdb (vsftpd: auth): user 'jack' granted access

Systemd [1]: Started Vsftpd ftp daemon.

Test

// Test the anonymous account

# Ftplocalhost

Trying: 1...

Connected to localhost (: 1 ).

220 (vsFTPd 3.0.2)

Name (localhost: root): anonymous

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

Ftp> ls

229 Entering Extended Passive Mode (||| 61057 | ).

150 Here comes the directory listing.

-Rw-r -- 1 0 0 9 Aug 11 :45 open.txt

226 Directory send OK.

Ftp> LCD/tmp

Local directory now/tmp

Ftp> getopen.txt

Local: open.txt remote: open.txt

229 Entering Extended Passive Mode (||| 64276 | ).

150 Opening BINARY mode data connection foropen.txt (9 bytes ).

226 Transfer complete.

9 bytes encoded ed in 0.000895 secs (10.06 Kbytes/sec)

Ftp> bye

221 Goodbye.

Vsftpd 530 Login incorrect error and 530 Permission denied error Solution

This error occurs when you log on to vsftpd as a root user today.

530 Login incorrect error and 530 Permission denied error.

530 Permission denied
Userlist_enable = YES in/etc/vsftpd. conf
/Etc/vsftpd/user_list contains the root list

Solution
Userlist_enable = NO

Remove root from user_list

Remove root from/etc/vsftpdftpusers

Common Faults:

Q: Logon Failed.

[Plain]

500 OOPS: cannot change directory:/home/vsftpd

Login failed.

421 Service not available, remote server has closed connection

A: Solution

Www.2cto.com

This is usually caused by SELinux. The solution is as follows:

Vi/etc/selinux/config

# Change selinux = enforcing or permissive to disabled and disable selinux,

Setenforce 0

# Enable the selinux policy to take effect immediately

/Etc/init. d/vsftpd restart

# Restart the FTP service

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.