1

I am looking to be able to SFTP a file from one linux server to Red Hat 8 server on AWS EC2.

I have created a user called sftpuser and want all files that are SFTP'd to this user to land in /testdata/sftp/incoming/.

I have managed to get this working only when I make root the owner of both /testdata and /testdata/sftp, but I need /testdata to be owned by another Linux user, and giving any group/other permissions stops the SFTP from working.

Match User sftpuser
        ChrootDirectory /testdata/sftp/incoming
        AllowTcpForwarding no
        X11Forwarding no
        ForceCommand internal-sftp

Is it possible to sftp files to that incoming folder but allow another user to own /testdata?

Thanks

1 Answer 1

0

why do you want /testdata directory to be owned by another user? As sftp internal-sftp used ChrootDirectory requirements, all specified path must be owned by the the root user only.

One good way is to change your configuration for sftpuser user like:

Match User sftpuser
        ChrootDirectory /testdata/sftp/
        AllowTcpForwarding no
        X11Forwarding no
        ForceCommand internal-sftp

Note that we removed incoming directory; then reload the configuration:

sudo systemctl reload sshd.service
### sudo service ssh reload      ## use this command if not a systemd 

now create incoming directory with that specific sftpuser user/group permission individually like:

sudo mkdir /testdata/sftp/incoming
sudo chown sftpuser /testdata/sftp/incoming
sudo chmod 755 /testdata/sftp/incoming

now, the sftpuser have read/write access to /testdata/sftp/incoming/ path.

1
  • Thanks for your reply, people will be sending large files through SFTP to the /testdata/sftp/incoming folder, I have 1TB provisioned to /testdata and all other folders have a combined total of 100gb as a boot volume so I need the file to go directly to a folder within /testdata. Also /testdata needs to be read/writable by another linux service user to read and write data down, not root.
    – Sts01
    Dec 10, 2020 at 22:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .