Access FTP based on virtual user
Turn off the firewall, SELinux
The process is as follows
1, packaging, configuration, service
The configuration process is as follows:
The content to be written to the vsftpd.conf configuration file is as follows:
Anonymous_enable=no----Anonymous users can log in
Local_enable=yes----Local Users can log in
Write_enable=yes----can write
local_umask=022 Setting the Umask value-----
Dirmessage_enable=yes----Catalog Welcome information feature
Xferlog_enable=yes----Enable logging
Connect_from_port_20=yes----link port is 20
Xferlog_std_format=yes----Log Format
Listen=yes----Turn on the monitor (must be turned on) RHEL7 can not open
PAM_SERVICE_NAME=VSFTPD----PAM module to verify user identity
Userlist_enable=yes----Open list mechanism
Tcp_wrappers=yes-----Support Firewall
1. Yum provides */db_load find the package that needs to install the database build tool, install it
RHEL7 need to install Libdb-utils
2. Create a virtual user list
Vim/etc/vsftpd/vsftp.users a virtual user file with one row for the user name and password
Xixi
123
haha
456
Db_load-t-T hash-f/etc/vsftpd/vsftp.users/etc/vsftpd/vsftp.users.db---Generating user database files
-T---support multi-software identification
-T---specifying the encryption algorithm
-F---The specified file
3. Create a non-logged-on user to use as a virtual user for a shared directory provider
useradd-d/var/ftproot-s/sbin/nologin Vftpuser
chmod 755/var/ftproot-Give write access to other users
4. Establish a virtual user login authentication Pam module
Vim/etc/pam.d/vuserftp
#%pam-1.0
Auth Required pam_userdb.so Db=/etc/vsftpd/vsftp.users
Account Required Pam_userdb.so Db=/etc/vsftpd/vsftp.users
5. Modify the master configuration file to support virtual user authentication Login
Chroot_local_user=yes
Guest_enable=yes
Guest_username=vftpuser corresponds to the user created above
User_config_dir=/etc/vsftpd/vuserdir set a directory, restart the service automatically generated
Pam_service_name=vuserftp corresponding to the above/etc/pam.d/vuserftp file
/ETC/INIT.D/VSFTPD restart
If access error refusing to run with writable root inside Chroot ()
Configuration file Write Allow_writeable_chroot=yes
Restart Service
Touch/etc/vsftpd/vuserdir/xixi
Touch/etc/vsftpd/vuserdir/hahavi
6. Create different permissions for a virtual user
Vim/etc/vsftpd/vuserdir/xixi
Anon_upload_enable=yes
anon_umask=022
Experimental results:
Xixi users can upload and download
haha users can only download, cannot upload
There are firewalls that need to be set up including SELinux
Virtual User of FTP