Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SFTP Read/Delete Access Only [closed]

Tags:

ssh

sftp

I would like to setup a server with the ability for users to use SFTP to download files we have placed in their user folder and delete them. But not to be able to leave their folders. I was able to get that to work, but it had the unexpected issue of causing the regular users on the server to no longer be able to upload files to the server.

I am requiring the user to use a Password and SSH Key to login.

The setup I went with was:

addgroup --system sftponly

vim /etc/ssh/sshd_config

AuthenticationMethods publickey,password
PubkeyAuthentication yes
PasswordAuthentication yes

Subsystem sftp internal-sftp -P write

Match Group sftponly
        ChrootDirectory /home/%u
        ForceCommand internal-sftp -P write
        X11Forwarding no
        AllowTcpForwarding no

When Adding a User:
usermod -G sftponly $username
chown root:root /home/$username
chmod 755 /home/$username
mkdir /home/$username/ftp
chown $username:$username /home/$username/ftp

I would then put their user files in the FTP folder. Which they were able to read from and delete their own files.

What can I do to make a normal user (one not part of the sftponly group) able to upload files?

like image 322
Daryl Avatar asked Aug 02 '26 03:08

Daryl


1 Answers

Leave the Match Group as is. Edit the "Subsystem" line.

From this: Subsystem sftp internal-sftp -P write

To this: Subsystem sftp internal-sftp

like image 188
Austin Avatar answered Aug 07 '26 12:08

Austin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!