Install and configure the FTP server in CentOS 7

Source: Internet
Author: User

Install and configure the FTP server in CentOS 7

Install and configure the FTP server in CentOS 7.

Suppose we have the following requirements:

Path Permission Remarks
/Ftp/open All staff of the company, including guests, can access Read-Only
/Ftp/private Only Alice, Jack, and Tom are allowed to access

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.

// Test the local account
# Ftplocalhost
Trying: 1...
Connected to localhost (: 1 ).
220 (vsFTPd 3.0.2)
Name (localhost: root): alice
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 (||| 21750 | ).
150 Here comes the directory listing.
226 Directory send OK.
Ftp>! Ls/tmp
Filetest1.txt open.txt systemd-private-9xPN7y vmware-fonts0 vmware-installer1 vmware-root vmware-tools-distrib
Ks-script-_ Yi85R SAMBA.docx vmware-config0 vmware-installer0 vmware-installer2 vmware-root-2117481760 yum. log
Ftp> LCD/tmp
Local directory now/tmp
Ftp> putfiletest1.txt
Local: filetest1.txt remote: filetest1.txt
229 Entering Extended Passive Mode (||| 65399 | ).
150 OK to send data.
226 Transfer complete.
9 bytes sent in 5.9e-05 secs (152.54 Kbytes/sec)
Ftp> bye
221 Goodbye.

Simple and practical Ubuntu FTP setup

Set up FTP server and Apache server on Ubuntu

Install the LAMP \ vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Simple case of anonymous uploading of SeLinux and vsftpd on the RHEL6 Platform

Install vsftpd source code in Linux

Case study of vsftpd Security Configuration

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.