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?
Leave the Match Group as is. Edit the "Subsystem" line.
From this: Subsystem sftp internal-sftp -P write
To this: Subsystem sftp internal-sftp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With