1

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.

3 Answers 3

2

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.

1
  • 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, 2012 at 19:49
1

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

2
  • 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, 2012 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, 2012 at 14:52
0

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.

1
  • Please do not only post a link but also at least summarize the content in case the link is broken. Sep 14, 2012 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .