Compile and deploy the vsftp service in Linux, and compile vsftp in linux.
DeploymentVsftpService
Hostname |
OS |
IP |
Software |
Vsftpsvr |
RHEL-5.8 |
10.0.0.58 |
Yum install-y vsftpd Yum install-y db4 |
Disable firewall: service iptables stop
Configure vsftpd service
[Root @ vsftpdsvr ~] # Yum install-y vsftpd // install the vsftpd package
[Root @ vsftpdsvr ~] # Mkdir-p/var/ftp/xuhao/sybg // create an ftp directory
Create a user and specify the home directory as the ftp directory
[Root @ vsftpdsvr ~] # Useradd-d/var/ftp/xuhao/-s/sbin/nologin xuhao
[Root @ vsftpdsvr ~] # Useradd-d/var/ftp/xuhao/sybg/-s/sbin/nologin xueyuan
[Root @ vsftpdsvr ~] # Passwd xuhao
[Root @ vsftpdsvr ~] # Passwd xueyuan
Set permissions for the ftp directory/var/ftp/xuhao. The owner is xuhao, the group is xueyuan, and the permission is 735
[Root @ vsftpdsvr ~] # Chown-R xuhao. xueyuan/var/ftp/xuhao/
[Root @ vsftpdsvr ~] # Chmod-R 735/var/ftp/xuhao/
Modify the main configuration file of vsftpd. conf
[Root @ vsftpdsvr ~] # Vim/etc/vsftpd. conf
Anonymous_enable = YES // Allow Anonymous Access
Local_enable = YES // allow local access
Write_enable = YES // write permission allowed
Enable vsftpd
[Root @ vsftpdsvr ~] #/Etc/init. d/vsftpd start
Starting vsftpd for vsftpd: [OK]
Verify
Build vsftpd service based on virtual users
Create a virtual user name/Password Database (/etc/vsftpd/vusers. list)
[Root @ vsftpdsvr ~] # Touch/etc/vsftpd/vusers. list
User1
12345
User2
123456
Install the db_load tool to convert it to a DB database file.
[Root @ vsftpdsvr ~] # Yum install-y db4
[Root @ vsftpdsvr ~] # Db_load-T-t hash-f/etc/vsftpd/vusers. list/etc/vsftpd/vusers. db
[Root @ vsftpdsvr ~] # File/etc/vsftpd/vusers. db
/Etc/vsftpd/vusers. db: Berkeley DB (Hash, version 8, native byte-order)
Create the FTP root directory and the system account corresponding to the virtual user
[Root @ vsftpdsvr ~] # Mkdir-p/var/ftp2
[Root @ vsftpdsvr ~] # Useradd-d/var/ftp2/-s/sbin/nologin virtual
[Root @ vsftpdsvr ~] # Chown-R virtual/var/ftp2/
[Root @ vsftpdsvr ~] # Chmod-R 777/var/ftp2 // modify directory permissions
Create a PAM Authentication file (/etc/pam. d/vsftpd. vu)
Auth required pam_userdb.so db =/etc/vsftpd/vusers
Auth required pam_userdb.so db =/etc/vsftpd/vusers
Modify the main configuration file of vsftpd. conf and add virtual user support
[Root @ vsftpdsvr ~] # Vim/etc/vsftpd. conf
Anonymous_enable = NO
Local_enable = YES
Pam_service_name = vsftpd. vu
Guest_enable = YES
Guest_username = virtual
User_config_dir =/etc/vsftpd/vusers_dir
Create independent configuration directories and files for users
[Root @ vsftpdsvr ~] # Mkdir/etc/vsftpd/user_dir
[Root @ vsftpdsvr ~] # Vim/etc/vsftpd/user_dir/user1
Anon_upload_enable = YES // upload allowed
Anon_mkdir_write_enable = YES // Folder creation allowed
Anon_other_wirte_enable = YES // allow deletion and rename
[Root @ vsftpdsvr ~] # Touch/etc/vsftpd/user_dir/user2
Restart vsftpd