Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need a user with specific homefolder. This user should read and write in his folder. And he cant read any other folder in the server.

share|improve this question
2  
What OS? People are answering based on assumptions but assumptions are the mother of all stuff-ups. –  John Gardeniers May 28 '11 at 12:13
add comment

4 Answers 4

up vote 2 down vote accepted

There are two possible ways of achieving this.

The first is to build a chroot environment for that user. To do that it is required that you build a new root with all the necessary binaries, libs and such for that user to work. It is quite complicated and especially if you are somewhat new to using *nix.

If you only require that the user has access to the files that can be done through SFTP if you use an OpenSSH version above 4.9 without any extra add-ons or modifications. I have written a blog post on this subject here: http://blog.frands.net/sftp-only-chroot-users-with-openssh-in-debian-166/

share|improve this answer
add comment

To add a user just use the following command

adduser <username>

As for how to restrict them to their home directory hopefully the answers to this question will help

share|improve this answer
add comment

The best method to bind a user to his home directory is to use "rbash" which stands for "restricted" bash. Using this, not only the user won't have any permissions to other directories but his home. He won't be able to change directory to elsewhere (cd /root will be denied, for example)

To do this, open /etc/passwd with root access using any editor (vi, vim or nano) after the user and his/her home directory are created. Find the line which contains the user record and simply replace /bin/bash with /bin/rbash

share|improve this answer
add comment

To add a user with home folder you can use this command (on ubuntu):

useradd -d /home/username -m username
passwd username 
share|improve this answer
    
That's not what he is asking. –  Frands Hansen May 28 '11 at 11:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.