I have seen this asked before, but none of the solutions works for me. I managed to make sftp login for a user, but I didn't manage to give the user permission to upload.
As far as I can understand, I am using OpenSSH's SFTP subsystem (ftp over ssh, port 22, and not a separate FTP server software):
$ ps -ef | grep sftp-server
otheruser 61324 32347 0 14:57 pts/0 00:00:00 grep --color=auto sftp-server
This is the sshd_config:
Include /etc/ssh/sshd_config.d/*.conf
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp internal-sftp
Match User user1
ChrootDirectory /sftp_files/uploads
folder permissions:
$ ls -ld /sftp_files/uploads
drwxr-xr-x 2 root root 4096 Jan 10 14:10 /sftp_files/uploads
$ ls -ld /sftp_files
drwxr-xr-x 3 root root 4096 Jan 9 15:15 /sftp_files
$ id user1
uid=1001(user1) gid=1001(user1) groups=1001(user1),0(root),125(ftp)
with the above permissions (755 on /sftp_files/uploads), I manage to login, read and download files. but when I try to upload I am getting Permission denied. Error code: 3
If I set:
sudo chmod 775 /sftp_files/uploads
While I am already logged in, I manage to upload files, but after logout, I am not able to login again. The error is:
fatal: bad ownership or modes for chroot directory "/sftp_files/uploads"
Is there any way to allow the user to upload the files?