Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to give SSH read only access to a certain directory so they can look at my PHP code.

The directory is /var/www/html/websitenamehere/

How can I make a user and let them login via SSH to see that directory and read it only? Is that possible?

I'm use to only logging in as root.

share|improve this question
The fact that you only login as root yourself is worrisome. Your system is almost certainly full of holes if that is the case and you should be concerned about giving anybody access to the box at all until your own habits are cleaned up and locked down. – Caleb May 3 '11 at 7:58
up vote 1 down vote accepted

Something like:

useradd readonlyuser

passwd readonlyuser (*if you want password auth, otherwise, setup SSH keys)

chmod -R o+rx /var/www/html/websitenamehere/

usermod -d /var/www/html/websitenamehere/ readonlyuser

Or you could just make a tarball of the filesystem and mail it to the user with something like tar cfvz websitenamehere.tar.gz /var/www/html/websitenamehere/

share|improve this answer

Your Answer


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.