Skip to content

Instantly share code, notes, and snippets.

@bbrothers
Last active June 17, 2023 11:20
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save bbrothers/8549960 to your computer and use it in GitHub Desktop.
Save bbrothers/8549960 to your computer and use it in GitHub Desktop.
Bash for creating vsftp users
#!/bin/bash
# Create ftp user, create folders and set permissions
# Shamelessly coppied from http://dev.n0ise.net/2012/09/vsftpd-add-user-automation-bash-script/
# Usage: ./create_ftp_user.sh [username] "[password]"
#
NAME=$1
PASS=$2
echo "USAGE: create_ftp_user.sh [username] [password]"
# check input parameters
if [ -z "$NAME" ]; then
echo "Error: username is not set"
exit
fi
if [ -z "$PASS" ]; then
echo "Error: password not set"
exit
fi
# create system user
echo "Creating user: $NAME"
echo "With password: $PASS"
#adduser $NAME
#passwd $PASS
useradd -p `openssl passwd -1 $PASS` $NAME
# save to users log
echo "user: $NAME, pass: $PASS" >> new_ftp_users_list
# add user to ftp daemon list
echo "$NAME" >> /etc/vsftpd.chroot_list
# create user ftp dir
mkdir /var/ftpupload/$NAME
# Set Ownership
chown $NAME:$NAME /var/ftpupload/$NAME
# Set permissions
chmod 0777 /var/ftpupload/$NAME
# restart vsftp daemon
#/etc/init.d/vsftpd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment