How to allow user to upload data on specific folder in RHEl 7

Posted October 17, 2020 1.4k views
Linux BasicsFedora

I have a scenario where users wants to upload images on specific folder (very long path) on the server. There is no FTP server installed? what is the best way to achieve this scenario.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there @skmusthaq,

I would recommend using SFTP in this case. You can take a look at this tutorial here on how to set that up for CentOS 7:


by Mateusz Papiernik
SFTP stands for SSH File Transfer Protocol. As its name suggests, it's a secure way of transferring files to a server using an encrypted SSH connection. n a standard configuration, the SSH server grants file transfer access and terminal shell access to all users with an account on the system. In this tutorial, we'll set up the SSH daemon to limit SFTP access to one directory with no SSH access allowed on per user basis.
  • Thank you very much for your reply. I have done that and it works fine but my scenario is something different i mean i have folder and owner of the files is different not root user If the folder owner is “root” user it works fine but if the file owner different user then it’s won’t work. is there any possibilities to workaround?

    Example :
    $user1:group1 755 /test1/test2/test3/test4/upload/file.txt

    $sudo chmod 777 /test1/test2/test3/test4/upload

    i created new sftp user sftpuser1

    $ sudo vi /etc/ssh/sshd_config
    Match User sftpuser1
    ForceCommand internal-sftp
    PasswordAuthentication yes
    ChrootDirectory /test1/test2/test3/test4/
    PermitTunnel no
    AllowAgentForwarding no
    AllowTcpForwarding no
    X11Forwarding no

    This scenario it doesn’t work because owner of the directory is different than root.

    if i create new folder with root as a owner then it works.

    $root:root 755 /test1/test2/test3/test4/upload/file.txt

    so is there a way to work for different user and group owners?