I am getting following error in auth.log when trying to connect to site using SFTP.
fatal: bad ownership or modes for chroot directory "/var/www"
ls -ld of this directory shows this:
drwxrwxr-x 4 root sftponly 4096 Aug 12 04:05 /var/www/
As you can see I have given full permission to group sftponly. The user through which I am connecting to SFTP is mysftpuser which is part of sftponly group.
If I do following then I can connect but cannot rename, edit, delete, overwrite any file or folder inside www
sudo chmod 755 /var/www/
Here's my sshd_config setting
Match group sftponly
ChrootDirectory /var/www
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
So in short sudo chmod 755 /var/www/ allows me to connect but only in READ only mode. sudo chmod 775 /var/www/ doesn't even allow me to connect.
How to fix this issue?
/var/wwwbut it has the same issue. Even if I give 777 permission on/var/wwwthen I cannot connect to SFTP. It will only connect if/var/www/has 755 permission but then it won't let me delete, rename etc. – Frank Martin Aug 12 '17 at 16:02chmod -R 775 /var/www. – doriclazar Aug 12 '17 at 16:34sftponlygroup to have read, write, and optional - to execute all enclosed files and folders. You achieve that by:chmod -R 775 /var/www, and by making this group owner of child files and directories:chown -R root:sftponly /var/www. – doriclazar Aug 13 '17 at 15:08