CodexBloom - Programming Q&A Platform

implementing file permissions and SFTP configuration on Ubuntu 20.04 server

πŸ‘€ Views: 24 πŸ’¬ Answers: 1 πŸ“… Created: 2025-05-31
linux sftp permissions ubuntu bash

Could someone explain I'm sure I'm missing something obvious here, but I've hit a wall trying to I'm building a feature where I'm trying to figure out I'm stuck on something that should probably be simple. I'm working with a scenario with setting up SFTP on my Ubuntu 20.04 server. I've configured the SSH daemon to allow SFTP access, but users in a specific group are unable to write to their assigned directories. Here’s what I did in `/etc/ssh/sshd_config`: ```bash Subsystem sftp internal-sftp Match Group sftpusers ChrootDirectory /home/sftp/%u ForceCommand internal-sftp AllowTcpForwarding no ``` The directory structure is as follows: ``` /home/sftp/ β”œβ”€β”€ user1/ β”‚ └── uploads/ └── user2/ └── uploads/ ``` Both `user1` and `user2` are members of the `sftpusers` group. I've set their home directories with the following commands: ```bash sudo mkdir -p /home/sftp/user1/uploads sudo mkdir -p /home/sftp/user2/uploads sudo chown root:root /home/sftp/user1 sudo chown root:root /home/sftp/user2 sudo chown user1:sftpusers /home/sftp/user1/uploads sudo chown user2:sftpusers /home/sftp/user2/uploads sudo chmod 755 /home/sftp/user1 sudo chmod 755 /home/sftp/user2 sudo chmod 770 /home/sftp/user1/uploads sudo chmod 770 /home/sftp/user2/uploads ``` I've confirmed that the group ownership and permissions are correct, but when `user1` tries to upload a file via SFTP, they receive this behavior message: ``` Upload failed, permission denied ``` I’ve tried restarting the SSH service with `sudo systemctl restart sshd`, but the scenario continues. I also checked the logs in `/var/log/auth.log` for any clues, but there's nothing that stands out. Could this be related to the way permissions are set or perhaps the chroot configuration? Any help would be greatly appreciated! This is part of a larger service I'm building. I'd really appreciate any guidance on this. This is my first time working with Bash stable. I'm using Bash 3.11 in this project. I'd really appreciate any guidance on this. I'm on Linux using the latest version of Bash. Thanks in advance! The project is a desktop app built with Bash. Has anyone else encountered this? I'm working in a Linux environment.