Last active
August 29, 2015 14:10
-
-
Save alihalabyah/05e5b82dc4dc696a464f to your computer and use it in GitHub Desktop.
Add SFTP user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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