Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # THIS SCRIPT CREATES A NEW USER AND TEMPORARORY PASSWORD
- # CHECK IF USER IS ROOT
- if [ ${UID} = 0 ]
- then echo "You are root, proceed"
- else
- echo "You are not root!"
- exit 1
- fi
- # ENTER LOGIN NAME
- read -p "Enter the username to create: " LOGIN
- # ENTER FULL NAME
- read -p "Enter the name of the person or application that will be using this
- account: " COMMENT
- # CREATE USER
- useradd -c "${COMMENT}" ${LOGIN}
- # ENTER INITIAL PASSWORD
- read -p "Enter the password to use for the account: " PASSWORD
- echo "Changing password for user ${LOGIN}."
- echo ${PASSWORD} | passwd --stdin ${LOGIN}
- # EXPIRE TEMPORARY PASSWORD
- passwd -e ${LOGIN}
- #DISPLAY LOGIN, HOSTNAME, AND PASSWORD
- printf "\nusername:\n${LOGIN}\n\n"
- printf "password:\n${PASSWORD}\n\n"
- printf "host:\n${HOSTNAME}\n"
Add Comment
Please, Sign In to add comment