Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ####
- # This script automatically creates user accounts with random passwords.
- #
- # Author: Russ Sanderlin
- # Date: 01/21/15
- #
- ###
- if [ $# -lt 1 ]; then
- echo "Please supply a user name"
- echo "Example: " $0 "jsmith"
- exit
- fi
- # Declare local variables, generate random password.
- newuser=$1
- randompw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
- # Create new user and assign random password.
- useradd $newuser
- echo $newuser:$randompw | chpasswd
- echo "UserID:" $newuser "has been created with the following password:" $randompw
Add Comment
Please, Sign In to add comment