Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- #!/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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement