This question already has an answer here:
I'm trying to let create a user with SFTP permissions to only one directory (that is not his home directory). When he connects through a SFTP client I want him to land on this directory and I don't want him to be able to view any other directory unless it's a sub-directory. I'm using Ubuntu 12.04.
I followed the steps below:
Edit the /etc/ssh/sshd_config file.
Add or modify the Subsystem sftp line to look like the following:
Subsystem sftp internal-sftp
Add the below block of text to the bottom of the file:
Match Group filetransfer ChrootDirectory %h X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp
service ssh restart
Create a system group for users whom you want to restrict to SFTP access:
addgroup --system filetransfer sudo adduser username #added user usermod -G filetransfer username #added him to the group chown root:root /home/username #disabled access to his default home directory chmod 755 /home/username
Changed the permissions directory I want him to be able to modify:
cd /srv/www/website_name/public_html/wp-content/themes/ chown username:filetransfer specific_folder chown username:filetransfer specific_folder/*
Set this folder as his home directory:
sudo usermod -d /srv/www/website_name/public_html/wp-content/themes/specific_folder username
But now I'm not able to connect using SFTP. This fails after I change his home directory. What should I do to fix this?