Vsftpd-2.2.2-11 installation under CentOS6.5 (virtual user)

Source: Internet
Author: User
Tags custom name
# The vsftpd service is CentOS6.5 built-in image # check whether there is a mounted Image CD df-ThFilesystemTypeSizeUsedAvailUse % Mountedon/dev/mapper/VolGroup-lv_rootext41

# The vsftpd service used is a built-in image of CentOS6.5.

# Check whether an image disc is attached
Df-Th
Filesystem Type Size Used Avail Use % Mounted on
/Dev/mapper/VolGroup-lv_root ext4 18G 3.4G 14G 21%/
Tmpfs 491 M 72 K 491 M 1%/dev/shm
/Dev/sda1 ext4 485 M 35 M 426 M 8%/boot


# Create a/mnt/cdrom CD mounting directory and mount the CD to this directory, prompting read-only mounting
Mkdir/mnt/cdrom & mount/dev/cdrom/mnt/cdrom
Mount: block device/dev/sr0 is write-protected, mounting read-only

------------------------------------------------------------
# Create a yum configuration file backup folder to back up the yum configuration file of the original system
Mkdir/etc/yum. back


# Move all the original configuration files under the yum. repos. d configuration file directory to the created yum configuration file backup directory
Cd/etc/yum. repos. d/& mv */etc/yum. back/

# Create an optical drive yum installation service. The yum configuration file is named cdyuminstall. repo.
Touch/etc/yum. repos. d/cdyuminstall. repo


# Write the following configuration information in the configuration file
Vim/etc/yum. repos. d/cdyuminstall. repo
[Cdinstall]
# Custom name
Name = cdinstall
# Custom name
Baseurl = file: // mnt/cdrom
# Custom Path, which is the disk Mount Directory

Enabled = 1

# Whether to enable yum source. 0 indicates disabled, and 1 indicates enabled.
Gpgcheck = 0
# Whether to check the GPG-KEY, 0 is not checked, 1 is checked # configured wq save to exit
Yum clean all
# Clear yum cache after configuration
------------------------------------------------------------
# Install the vsftpd service that comes with the CD
Yum install vsftpd
# Wait until the installation is complete to view the installed service information
Rpm-q vsftpd
Vsftpd-2.2.2-11.el6_4.1.x86_64
# Back up the vsftpd configuration file to prevent irreparable configuration errors. customize the backup name vsftpd. conf. bak
Cp/etc/vsftpd. conf/etc/vsftpd. conf. bak
# Import the configuration file vsftpd. conf. bak after the backup to the configuration file vsftpd. conf.
Cd/etc/vsftpd
Grep-vi "#" vsftpd. conf. bak | grep-vi ^ $> vsftpd. conf
# View the exported configuration file information
[Root @ localhost vsftpd] # cat vsftpd. conf
Anonymous_enable = YES
Local_enable = YES
Write_enable = YES
Local_umask = 022
Dirmessage_enable = YES
Xferlog_enable = YES
Connect_from_port_20 = YES
Xferlog_std_format = YES
Listen = YES
Pam_service_name = vsftpd
Userlist_enable = YES
Tcp_wrappers = YES
[Root @ localhost vsftpd] #
# Determine the system integration db4 version
Rpm-q db4
Db4-4.7.25-18.el6_4.x86_64
# Create a custom named temporary text file and write it into the virtual user name and password
Vim vusers.txt
[Root @ localhost vsftpd] # cat vusers.txt
Test
# Virtual user account
Test
# Virtual user password
[Root @ localhost vsftpd] #
# Load the text you just created to a custom database Virtual User
Db_load-T-t hash-f vusers.txt vsftpd-virtual-user.db
# Create a pam authentication configuration file and specify the path of the database file
Vim/etc/pam. d/vsftpd. virtual
[Root @ localhost vsftpd] # cat/etc/pam. d/vsftpd. virtual
Auth required/lib64/security/pam_userdb.so db =/etc/vsftpd-virtual-user
Account required/lib64/security/pam_userdb.so db =/etc/vsftpd-virtual-user
[Root @ localhost vsftpd] #
# Create a virtual user configuration directory to store Virtual User configuration information
Mkdir-pv/etc/vsftpd/vhome
# Create a home directory for virtual user logon
Mkdir/usr/html
# Assign permissions to the new virtual user test that has been created and imported into the database
Vim/etc/vsftpd/vhome/test
[Root @ localhost vsftpd] # cat/etc/vsftpd/vhome/test
Anon_world_readable_only = NO
Anon_upload_enable = YES
Anon_mkdir_write_enable = YES
Anon_other_write_enable = YES
Anon_umask = 033
Local_root =/usr/html/

[Root @ localhost vsftpd] #
# Create a system user web and assign directory permissions to the user
Useradd-s/sbin/nologin-c "web" web
Chown-R web. web/usr/html
# The directory must not be writable.
Chmod a-w/usr/html
# Add virtual user configuration information to the vsftpd. conf configuration file
[Root @ localhost vsftpd] # cat vsftpd. conf
Anonymous_enable = YES
Dirmessage_enable = YES
Xferlog_enable = YES
Connect_from_port_20 = YES
Listen = YES
Userlist_enable = YES
Tcp_wrappers = YES
Use_localtime = YES
Local_enable = YES
Write_enable = YES
Anon_world_readable_only = NO
Guest_enable = YES
Guest_username = web
Pam_service_name = vsftpd. virtual
Xferlog_std_format = YES
Dual_log_enable = YES
Vsftpd_log_file =/var/log/vsftpd. log
Xferlog_file =/var/log/xferlog
User_config_dir =/etc/vsftpd/vhome

[Root @ localhost vsftpd] #

# Modify the configuration file information and restart the corresponding service
[Root @ localhost vsftpd] # service vsftpd restart
Disable vsftpd: [OK]
Start vsftpd for vsftpd: [OK]
[Root @ localhost vsftpd] #
Setenforce 0

# Temporarily disable selinux mode. Otherwise, an error will be reported after you log on to the virtual account. you can also permanently disable the selinux configuration file SELINUX = disabled to restart the server.


--------------------------------------------------------
# Create a directory and file in the vsftp access directory for testing
Mkdir/usr/html/test111 & touch/usr/html/222
# Install lftp for access testing
Yum install lftp
# Try to log on to the test using a Virtual User
[Root @ localhost vsftpd] # lftp 127.0.0.1
Lftp 127.0.0.1: ~> User test
Password: test
Lftp test@127.0.0.1: ~> Ls
-Rw-r -- 1 500 500 0 Dec 01 111
Drwxr-xr-x 2 0 0 4096 Dec 01 07:51 Test1
Lftp test@127.0.0.1:/>

------------------------- END -----------------------

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.