0

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.

Kline
  • 247
  • 1
  • 5
  • 17
  • Do you change the homedir of the users to the website dir ? – Dom Dec 04 '14 at 17:46
  • While the name of the home directory is typically the same as the username, there's no rule requiring it to be. The name of the directory is irrelevant. Are you really trying to ask how to share the same home directory with multiple accounts? –  Dec 04 '14 at 19:26
  • @Dom yes that is what usermod -m -d does – Kline Dec 04 '14 at 20:17
  • @yoonix this is what I thought but deleting the home directory of the sftp user seems to cause a problem. I can login to "website" via the new user but only if their home folder exists. – Kline Dec 04 '14 at 20:30
  • Right, you would make the website directory the home directory. That's why I'm asking if you are trying to share the directory. If it's just one user, make his home directory /whatever/you/want/website. If you need to *share* that directory between accounts, that's something else entirely. –  Dec 04 '14 at 20:42
  • I've made "website" the home directory for the new user (usermod -d) but deleting the new users directory is what causes the problem. I think I may have a different way around the actual problem though, I want to now use key access like described here http://serverfault.com/questions/485434/is-there-an-easier-way-to-add-public-key-authentication-for-new-users the only problem is that isn't working for me, I can get key access as root but not as a specific user. – Kline Dec 04 '14 at 22:50
  • Actually I have the key method working I had to delete the user folder and adduser again – Kline Dec 04 '14 at 23:27

1 Answers1

1

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.