Affichage des articles dont le libellé est specific directory. Afficher tous les articles
Affichage des articles dont le libellé est specific directory. Afficher tous les articles

mardi 18 mars 2014

Linux SSH - Limit user access to a specific directory

Make sure you are the SuperUser.


Create a user, by typing this command and following the process
adduser username

Specify user base directory to the directory you want
usermod --home /var/www username

If you want a group of users to only access this directory, add the user to a group
addgroup mygroup
usermod -g mygroup username 

Now, specify the directory to be exclusive. Go to "/etc/ssh" and type
nano sshd_config

Find and comment (# at the beginning) this line
Subsystem sftp /usr/lib/openssh/sftp-server

And write this
Subsystem sftp internal-sftp
Match group mygroup
    ChrootDirectory /var/www/
    X11Forwarding no
    AllowTcpForwarding no
    X11Forwarding no  
    ForceCommand internal-sftp


That's all, have fun.