In my VPS account, I have a folder /home/xyz/public_html.

This belongs to a customer who now wants their in-house developer to look into the code. How do I give SFTP access to only this folder?

I have already tried creating a user and giving access as follows, but when I login through WinSCP and change the directory to /, its going to all the root folders.

useradd dev1
groupadd dev-xyz    
usermod -a -G dev-xyz dev1
chown -R root /home/xyz/public_html
chgrp -R dev-xyz /home/xyz/public_html
chmod -R 775 /home/xyz/public_html
chmod g+s /home/xyz/public_html

EDIT 1 This is what I added in sshd_config & then restarted the service, but to no effect in outcome.

Match Group dev-xyz
ChrootDirectory /home/xyz/public_html
AllowTCPForwarding no
X11Forwarding no
ForceCommand /usr/libexec/openssh/sftp-server
  • You say FTP access but tag sftp and usage of WinSCP - do you really want an FTP solution or an SSH based solution? – DanSut Oct 9 '15 at 12:19
  • Yes, thats a mistake. Need a SSH based solution. Thanks for pointing out. – Souvik Oct 9 '15 at 13:09

You can use sshd(8) and the ChrootDirectory directive. It allows to chroot an SFTP account.

  • 1
    In combination with the Match User and ForceCommand directives you can force the use of SFTP in a way that the user can not login to a shell. – Lambert Oct 9 '15 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.