Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

We currently are only using a root ssh login to our server and are attempting to make a "developer" status user which should only have access to a sub directory.

Is there a way we can set it up so when the developer logins in, his root is a sub directory and all parent directories are hidden?

example : root login: root/www/location/ developer login: location/

Thank you.

share|improve this question
add comment

migrated from stackoverflow.com Sep 14 '12 at 19:25

This question came from our site for professional and enthusiast programmers.

3 Answers

I think what you're asking for is chroot.

That tutorial should be a sufficient walk through. SSH can't chroot (change root) for a user to jail them in their home directories.

The process is a little complicated (as explained at the bottom of the walk through) because all the required devices, programs and libraries will need to be visible in the user's path.

You might also try jailkit. I've never heard of this before now, but it seems to do what you need.

Now that I've answered your original question, it's worth noting that it's probably easier (and good enough) to just deny the development user write access to things you don't want them touching. chroot is really intended for non-shell users and SFTP.

share|improve this answer
    
You can set up the chroot environment for the user -- actually, set it up for several users -- and have their initial shell be a program that chroots and execs a real shell –  mpez0 Sep 14 '12 at 19:49
add comment

you can indicate the home directory of the developer by change the associated record of developer in the file /etc/passwd like this

developer:x:1000:0:developer,,,:HOME_DIRECTORY:/bin/bash

The HOME_DIRECTORY is where the developer will be when he logined in

share|improve this answer
    
Okay it is setup to the right directory but the issue is you can still see all the parent directories. How do I hide these from the user? We are trying to give our lower developers access to the "test-site" only –  Dom Sep 14 '12 at 14:46
    
@Dom give the root/www with the permission of root,say the developer has no "x" permission in these directory,will it work? –  cheneydeng Sep 14 '12 at 14:52
add comment

Is this what you're looking for?

They recommend

  1. Login as a user with sudo privileges.
  2. Enter this command:

sudo nano /etc/passwd

  1. Nano text editor opens up. Locate the username you would like to change the home directory of (the last added user is in the end), and just enter whatever directory you would like. For example, the home directory for the user jack is set to /home/jack in this file:

jack:x:1000:1000:Jack,,,:/home/jack:/bin/bash

But I want him to use a home directory of /home/whatever. So I just change the above line to:

jack:x:1000:1000:Jack,,,:/home/whatever:/bin/bash

Now when the user jack logs in, his home directory would be /home/whatever.

I'm not sure if this method will hide the parent directories, but you could restrict access.

EDIT: Added description as per comment.

share|improve this answer
    
Please do not only post a link but also at least summarize the content in case the link is broken. –  Nobody Sep 14 '12 at 14:40
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.