chrooted sftp :: fatal: bad ownership or modes for chroot directory component

If you have setup sftp in chrooted mode and you are unable to log into the server

$ sftp [email protected]

[email protected]’s password:
Connection to abcd.com closed by remote host.
Couldn’t read packet: Connection reset by peer

have a look at the /var/log/secure log and if you find the below error

 sshd[19490]: fatal: bad ownership or modes for chroot directory component “/var/www/vhosts/abcd.com/httpdocs/”

Fix is as below

# chmod 755 /var/www/vhosts/abcd.com/httpdocs/

# chown root:root /var/www/vhosts/abcd.com/httpdocs/

Ensure that the entire path from / to /var/www/vhosts/abcd.com/httpdocs/ have ownership of root user and is not writable by group or any other user. This is certainly one of the limitations of chrooted sftp.

 

Leave a Comment