ftp:virtual_users_in_vsftpd
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
ftp:virtual_users_in_vsftpd [2016/09/28 14:09] – peter | ftp:virtual_users_in_vsftpd [2019/11/29 14:39] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== FTP - Virtual users in VsFtpd ====== | ||
- | Virtual users are users that do not exist on the system - they are not in **/ | ||
- | |||
- | You can set different definitions to each virtual user, granting to each of these users different permissions. | ||
- | |||
- | The following example is based and adapted on the example for virtual users in vsftpd site, on documentation and the very good examples. | ||
- | |||
- | Currently there is a restriction that with **guest_enable enabled**, local users also get mapped to guest_username. | ||
- | |||
- | |||
- | ===== Create The Virtual Users Database ===== | ||
- | |||
- | To create a " | ||
- | |||
- | <code bash> | ||
- | mkdir /etc/vsftpd # if necessary. | ||
- | cd /etc/vsftpd | ||
- | sudo vi vusers.txt | ||
- | </ | ||
- | |||
- | and populate the file: | ||
- | |||
- | < | ||
- | john | ||
- | johnpass | ||
- | mark | ||
- | markpass | ||
- | </ | ||
- | |||
- | |||
- | ===== Create the actual database file ===== | ||
- | |||
- | **NOTE**: | ||
- | |||
- | <code bash> | ||
- | db_load -T -t hash -f vusers.txt vsftpd-virtual-user.db | ||
- | chmod 600 vsftpd-virtual-user.db # make it not global readable. | ||
- | rm vusers.txt | ||
- | </ | ||
- | |||
- | |||
- | ===== Configure VsFtpd for virtual user ===== | ||
- | |||
- | Edit the VsFtpd configuration file (/ | ||
- | |||
- | <code bash> | ||
- | vi / | ||
- | </ | ||
- | |||
- | and add or modify as: | ||
- | |||
- | < | ||
- | anonymous_enable=NO | ||
- | local_enable=YES | ||
- | # Virtual users will use the same privileges as local users. | ||
- | # It will grant write access to virtual users. Virtual users will use the | ||
- | # same privileges as anonymous users, which tends to be more restrictive | ||
- | # (especially in terms of write access). | ||
- | virtual_use_local_privs=YES | ||
- | write_enable=YES | ||
- | |||
- | # Set the name of the PAM service vsftpd will use | ||
- | pam_service_name=vsftpd.virtual | ||
- | |||
- | # Activates virtual users | ||
- | guest_enable=YES | ||
- | |||
- | # Automatically generate a home directory for each virtual user, based on a template. | ||
- | # For example, if the home directory of the real user specified via guest_username is | ||
- | # / | ||
- | # logs in, he will end up (usually chroot()' | ||
- | # This option also takes affect if local_root contains user_sub_token. | ||
- | user_sub_token=$USER | ||
- | |||
- | # Usually this is mapped to Apache virtual hosting docroot, so that | ||
- | # Users can upload files | ||
- | local_root=/ | ||
- | |||
- | # Chroot user and lock down to their home dirs | ||
- | chroot_local_user=YES | ||
- | |||
- | # Hide ids from user | ||
- | hide_ids=YES | ||
- | </ | ||
- | |||
- | Save and close the file. | ||
- | |||
- | |||
- | ===== Create a PAM File Which Uses Your New Database ===== | ||
- | |||
- | The following PAM is used to authenticate users using your new database. | ||
- | |||
- | <code bash> | ||
- | sudo vi / | ||
- | </ | ||
- | |||
- | and add or modify as: | ||
- | |||
- | < | ||
- | #%PAM-1.0 | ||
- | auth | ||
- | account | ||
- | session | ||
- | </ | ||
- | |||
- | |||
- | ===== Create The Location Of The Files ===== | ||
- | |||
- | You need to set up the location of the files / dirs for the virtual users. | ||
- | |||
- | <code bash> | ||
- | mkdir /home/vftp | ||
- | </ | ||
- | |||
- | and then create sub-directories for each virtual user. | ||
- | |||
- | <code bash> | ||
- | # mkdir -p / | ||
- | # chown -R ftp:ftp /home/vftp | ||
- | </ | ||
- | |||
- | |||
- | ===== Restart The FTP Server ===== | ||
- | |||
- | Type the following command: | ||
- | |||
- | <code bash> | ||
- | service vsftpd restart | ||
- | </ | ||
- | |||
- | |||
- | ===== Test Your Setup ===== | ||
- | |||
- | Open another shell session and type: | ||
- | |||
- | <code bash> | ||
- | ftp localhost | ||
- | </ | ||
- | |||
- | Sample success output: | ||
- | |||
- | < | ||
- | Connected to ftp.sharewiz.net. | ||
- | Name (localhost: | ||
- | 331 Please specify the password.[user now types in johnpass] | ||
- | Password: | ||
- | 230 Login successful. | ||
- | Remote system type is UNIX. | ||
- | Using binary mode to transfer files. | ||
- | ftp> | ||
- | </ | ||
- | |||
- | |||
- | ===== Troubleshooting ===== | ||
- | |||
- | The official Vsftpd documentation at ftp:// | ||
- | |||
- | By default files are created with permissions like **-rw**. | ||
- | |||
- | (and owned by the ftp user if using virtual users). | ||
- | |||
- | |||
- | ===== References ===== | ||
- | |||
- | * http:// | ||
- | * http:// | ||
- | |||
- | See Also | ||
- | |||
- | * http:// | ||
- | |||
- | This article pertains specifically to vsftpd on CentOS. |
ftp/virtual_users_in_vsftpd.1475071758.txt.gz · Last modified: 2020/07/15 09:30 (external edit)