The end goal here is to have an sftp user that logs into /home/user1/data

I have followed the instructions at the link below and they do work: https://www.vultr.com/docs/setup-sftp-only-user-accounts-on-centos-7

I created a dir /home/user1/data, and if I try to change the ChrootDirectory value in the sshd_config from %h to /home/user1/data, my logins fail.

I need the user to login to that specific directory, any advice is appreciated.

  • Been a long time andno longer have the system to check, but IIRC I did it by making the user's home dir under the chroot, ie, if you have /home/user1 then chrooting them to /home. Set shell to /bin/false or similar, etc put them in a group and use the group as your chroot on the sshd_config. Also you have to use the built-in sftp subsystem for it to work.
    – ivanivan
    Mar 22, 2019 at 1:31

1 Answer 1


Try setting ChrootDirectory back to %h, then set the home directory of user1 to /data. This assumes /home/user1 has a filesystem structure appropriate to chroot. You might need to modify the user1 home directory both in /etc/passwd, and in /home/user1/etc/passwd.

This wont lock user1 into the /home/user1/data directory, but that is where they will default to when logged in.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .