Multiple FTP Accounts for a single Domain in Linux

Login to server via SSH as root.
Issue the shell command:

#cat /etc/passwd |grep ‘jerry’

This will show you a line similar to the following:

jerry:x:10041:10001::/var/www/vhosts/example.com:/bin/false

The first number (after the 2nd colon : ) is 10041, so this is the UID of user jerry. You will need this in the ‘useradd’ lines since useradd wants a number for the UID.


Then run the following shell commands to create the users and passwords:
#useradd -u 10041 -o -d /var/www/vhosts/example.com -g jerry -s /bin/false mouse

#useradd -u 10041 -o -d /var/www/vhosts/example.com -g jerry -s /bin/false tomcat

#passwd mouse (enter the new password and confirm it)
#passwd tomcat (enter the new password and confirm it)

You should now be able to use an FTP client to login with that user’s name and password.

User jerry and tomcat should be able to see the example.com docroot just as user jerry can. You should NOT be able to browse above the example.com docroot directory. All 3 users should have the same access to the files since they belong to the same group, so no matter which of the users created or edited the file(s), all should be able to access/edit/whatever the same files.


If you wanted to change their default directory and limit them to a subdomain docroot, in the useradd line above, you would change “/var/www/vhosts/example.com” to “/var/www/vhosts/example.com/subdomains/subname”. So if you wanted to create the same users, but for a subdomain called ‘admin’:
Then do the following shell commands to create the users and passwords:

#useradd -u 10041 -o -d /var/www/vhosts/example.com/subdomains/admin -g jerry -s /bin/false mouse
#useradd -u 10041 -o -d /var/www/vhosts/example.com/subdomains/admin -g jerry -s /bin/false tomcat

#passwd jill (enter the new password and confirm it)
#passwd bob (enter the new password and confirm it)

Deleting an FTP user:

#userdel fptusername

0 comments:

Post a Comment