Skip to content

Instantly share code, notes, and snippets.

@WorldException
Created February 10, 2022 12:41
Show Gist options
  • Save WorldException/c07d247ab529d6b7df1f5e779e9f81c8 to your computer and use it in GitHub Desktop.
Save WorldException/c07d247ab529d6b7df1f5e779e9f81c8 to your computer and use it in GitHub Desktop.
sftp only home directory without login
#!/bin/bash
groupadd ftponly
useradd -s /bin/false uploader
usermod -aG ftponly uploader
passwd uploader
chown root:root /home/uploader
chmod 755 /home/uploader
systemctl restart sshd
...
# override default of no subsystems
# Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
Match group ftponly
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
PermitTTY no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment