5

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.

Caleb
  • 11,813
  • 4
  • 36
  • 49
Andrew Fashion
  • 1,655
  • 7
  • 22
  • 26
  • 1
    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 03 '11 at 07:58

1 Answers1

2

Something like:

  • Create the user
    useradd readonlyuser
    
  • Enter its password if you want password auth, otherwise, setup SSH keys
    passwd readonlyuser
    
  • Give Read and Execution permission to the directory Owner and all its sub-folders and files
    chmod -R o+rx /var/www/html/websitenamehere/
    
  • Set the home directory of the user
    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/
Sandra Rossi
  • 103
  • 4
dmourati
  • 25,540
  • 2
  • 42
  • 72