Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # check if executed as root
- if [[ ${UID} != 0 ]]
- then
- echo 'You are not root'
- exit 1
- fi
- # get details for the new account
- read -p 'Create user: ' USERNAME
- read -p 'Full name: ' FULLNAME
- read -p 'Set password: ' PASSWORD
- # create the account
- useradd $USERNAME -c "$FULLNAME" -m
- # check creation was successul
- if [[ $? != 0 ]]
- then
- echo 'Unable to create user'
- exit 1
- fi
- # set password and set as expired
- echo $PASSWORD | passwd --stdin $USERNAME
- passwd -e $USERNAME
- # echo details
- echo "Username: $USERNAME"
- echo "Password: $PASSWORD"
- echo "Host: $HOSTNAME"
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement