Skip to content

Instantly share code, notes, and snippets.

@fgbreel
Created November 19, 2012 16:50
Show Gist options
  • Save fgbreel/4111804 to your computer and use it in GitHub Desktop.
Save fgbreel/4111804 to your computer and use it in GitHub Desktop.
SFTP with OpenSSH
Subsystem sftp "internal-sftp -u 0002"
Match Group sftponly
ChrootDirectory %h
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp -u 0002
@frop
Copy link

frop commented Jan 21, 2016

Nice 👍

@fgbreel
Copy link
Author

fgbreel commented Jan 22, 2016

Remove from /etc/ssh/sshd_config any line containing sftp

Put the content above at the end of the file /etc/ssh/sshd_config

execute the commands below to create a group who will be matched on the rule of the snippet above, an user, and the correct directory permissions.

groupadd sftponly
useradd -s /bin/bash -G sftponly -m sftp-user
passwd sftp-user
chown root:root /home/sftp-user
mkdir /home/sftp-user/incoming && chown sftp-user /home/sftp-user/incoming

@diogenes
Copy link

Cool thing, man! 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment