Linux SFTP user without a home directory

linuxsftp

Suppose I have a home directory called "website".

I want to create an sftp user to access that home folder and the sftp user is going to have a less obvious user name. There may be quite a few users like this so I am wondering if I can create these new sftp users without a home directory of their own and send them to the "website" directory.

I tried this by using usermod -m -d and then deleting the new users home folder but got access denied when logging in.

Best Answer

Groups!

addgroup yourgroup

chgrp yourgroup /some/dir

Add the users you want to share this directory to the group.

usermod -g yourgroup user1
usermod -g yourgroup user2

Give group proper permissions to /some/dir. 775 is just an example.

chmod 775 /some/dir

Assign /some/dir as the home directory for your users.

usermod -d /some/dir user1
usermod -d /some/dir user2

Voila.