Skip to content

Instantly share code, notes, and snippets.

@jkullick
Last active July 29, 2016 12:10
Show Gist options
  • Save jkullick/3227de17d8813d081b1403c840b6db52 to your computer and use it in GitHub Desktop.
Save jkullick/3227de17d8813d081b1403c840b6db52 to your computer and use it in GitHub Desktop.
Add Chroot SFTP-only User (no shell access)
usermod -G sftp $USER
usermod -s /bin/false $USER
chown root:root /home/$USER
chmod 0755 /home/$USER
mkdir /home/$USER/uploads
chown $USER:$USER /home/$USER/uploads

/etc/ssh/sshd_config:

...
# Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp

Match Group sftp
   ChrootDirectory %h
   ForceCommand internal-sftp
   AllowTcpForwarding no
service ssh restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment