Setting up Virtual user with VSFTPD with Different PermissionsSetting up Virtual user with VSFTPD with Different Permissions

If you want to setup a virtual user with VSFTPD and also want to share the same directory across multiple users then you can refer the below simple steps to achieve this :

Install VSFTPD server

yum install vsftpd

Open the /etc/vsftpd/vsftpd.conf file and add the below contents :

 anonymous_enable=NO
 local_enable=YES
 chroot_local_user=YES
 user_config_dir=/etc/vsftpd/vsftpd-virtual-user/
 virtual_use_local_privs=YES
 dual_log_enable=YES
 connect_from_port_20=YES
 listen=YES
 pam_service_name=vsftpd
 local_root=/home/share-drive
 tcp_wrappers=YES
 pasv_enable=YES
 pasv_max_port=55000
 pasv_min_port=50000
 pasv_address=10.10.10.14
 local_umask=0002

save and quit

Here pasv_address=10.10.10.14 is explicitly used to map the nat IP to public IP for passive port

Now go to directory /etc/vsftpd/vsftpd-virtual-user/ and create the file :: vsftpd_user

cd /etc/vsftpd/vsftpd-virtual-user/

Note :: You need to create the directory : /etc/vsftpd/vsftpd-virtual-user/ if it doesn’t exist
In vsftpd_user file add the usernames for which you want to set per user configuration

root@server~[#] cat vsftpd_user
test
test1

Now create the usernames file as ::

root@server~[#] cat test
 local_root=/home/share-drive
cmds_allowed=USER,PASS,SYST,FEAT,OPTS,PWD,TYPE,PASV,LIST,STOR,CWD,MKD,SIZE,MDTM,CDUP,RETR,RNFR,RNTO
hide_file={.xml} deny_file={.xml}
file_open_mode=0666
local_umask=0002
write_enable=YES

Here, deny_file will limit the access to specific files and folders for user test and same will be used for hiding the files

To use the benefit of share/common directory add the users as ::

First create a group called : ftp_users

then add the users as ::

useradd -d /home/share-drive -s /sbin/nologin username

Once done that, use the command usermod -G ftp_users test this will facilitates all the files and folders creation with test:ftp_users .

To add new user use :

  useradd -d /home/share-drive -s /sbin/nologin -g  ftp-users test1

Finally, restart the VSFTPD service and you are done.