Skip to content

Instantly share code, notes, and snippets.

@alihalabyah
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alihalabyah/05e5b82dc4dc696a464f to your computer and use it in GitHub Desktop.
Save alihalabyah/05e5b82dc4dc696a464f to your computer and use it in GitHub Desktop.
Add SFTP user
# Add new user group
groupadd sftpusers
# Add new user set the directory, the main role and the user name
useradd -g sftpusers -d /dir -s /sbin/nologin username
# Make sure the user can perform SSH login
usermod username -s /sbin/nologin
# Make sure the user has been added
grep username /etc/passwd
# Set the user password
passwd username
Edit the following file /etc/ssh/sshd_config
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
Match Group sftpusers
ChrootDirectory /
ForceCommand internal-sftp
AllowTcpForwarding no
# Set the directory owner user:group format
chown -R checkout:sftpusers /dir
# Reset permissions
chmod 755 /dir
# Reload or Restart the SSH service
sudo service ssh reload
service ssh restart
/etc/init.d/ssh restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment