-
-
Save iturdikulov/1729818a2df0ed061462bd092ae325f6 to your computer and use it in GitHub Desktop.
Quick script for adding a new SFTP user/directory to an existing SFTP setup on Ubuntu.
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
#!/bin/sh | |
###################################################### | |
# Create a new SFTP user and configure their chroot | |
###################################################### | |
if [ $# -ne 2 ]; then | |
echo "Usage: add_sftp_user.sh username password" | |
exit 0 | |
fi | |
useradd -d /sftp -s /bin/false -G $(grep sftpusers /etc/group | cut -d: -f3) -p `mkpasswd -m SHA-512 $2` $1 | |
mkdir -p /sftp/$1/sftp | |
chown root:sftpusers /sftp/$1 | |
chown -R $1:sftpusers /sftp/$1/sftp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment