SFTP – Troubleshooting Authentication Failures

fedorasambasftpssh

I am trying to setup sftp access for our customers to download or upload files. While trying to setup the directory permissions and user access I keep getting errors as such.

server1 sshd[21760]: Accepted password for user01 from 192.168.1.118 port 51026 ssh2
server1 sshd[21760]: pam_unix(sshd:session): session opened for user user01 by (uid=0)
server1 sshd[21775]: fatal: bad ownership or modes for chroot directory "/home/user01"
server1 sshd[21760]: pam_unix(sshd:session): session closed for user user01

I have the following setup in the sshd_config file:

Match Group sftp_users
ChrootDirectory %h
ForceCommand internal-sftp

Folder/file permissions show as this:

drwxr-xr-x 4 user01 sftp_users 4096 Mar 28 09:26 /home/user01

I have a mounted drive as such:

//windowserver/ftproot/customers/user01 on /home/user01 type cifs (rw)

What I am failing to understand/determine is if the user "user01" has read/write access to it's own home directory on the local machine, but when using ssh/sftp the error of "bad ownership/modes" is returned. Is it because the session for user01 is opened by uid=0? In this case the uid for user01 is 502, while the uid for root is 0.

If additional information is needed from what I have given here, please let me know and I'll post that info.

Best Answer

Chroot directory should be the parent of the target so in this case /home

ChrootDirectory /home