I am trying to create a new SFTP account for my server. When I follow these instructions exactly, then everything works fine: https://www.thegeekstuff.com/2012/03/chroot-sftp-setup/
I can connect with the
guestuser user via
sftp, browse my home directory, and go one level up from
I can even change the
ChrootDirectory value in
/etc/ssh/sshd_config to specifically be
/sftp/guestuser, instead of implementing the
%u parameter. So hardcoded directory names therefore work fine.
But from that point, if all I do is change the
ChrootDirectory of my
sftpusers group to my actual website's directory on
/var/www/www.example.com, then I cannot connect via the
sftp command on that user anymore. The shell outputs:
Connection to www.example.com closed by remote host. Couldn't read packet: Connection reset by peer
I definitely did:
- Make sure I had the
incomingfolder in my
- Set the ownership of both
- Tried setting the home directory of user to
usermod guestuser -d /
/sftp/guestuser directory (the one with which it worked) is in the ownership of
root:root, so the fact that the permissions of
/var/www are on
root:root should not matter(?)
How come I cannot change the home directory of my new SFTP user?
I can change the directory to:
Those all work. But as soon as go one more under
/var/www/test, it doesn't work. I've tried removing the dots from the original directory name that was
www.example.com, but it didn't make a difference.
It's not about a limit on the number of subdirectory levels either, because
/sftp/guestuser/incoming also worked. Testing it with a new directory
/web/www.example.com did not.