-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-local-user.sh
More file actions
executable file
·38 lines (35 loc) · 888 Bytes
/
Copy pathadd-local-user.sh
File metadata and controls
executable file
·38 lines (35 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Check for root if not, exit with error 1
if [[ "$UID" = 0 ]]
then
# Promt user for Username and password
read -p "Please enter your desired user name: " USER_NAME
read -p "Please enter your real name: " COMENT
read -p "Please enter your desired password: " PASSWORD
#Create new user with input from the user
adduser -c "${COMENT}" -m ${USER_NAME}
echo ${PASSWORD} | passwd --stdin ${USER_NAME}
passwd -e ${USER_NAME}
else
echo "YOU ARE NOT ROOT!"
exit 1
fi
#Inform the user if the account is not created correctly with exit code 1
if [[ "${?}" -ne 0 ]]
then
echo " Adding this user, was unsuccessful!"
fi
#Dispaly username, password and host where the account is created for records
echo "Usernmae: "
echo " "
echo "${USER_NAME}"
echo " "
echo "Real Name: "
echo " "
echo "${COMENT}"
echo " "
echo "Password: "
echo " "
echo "${PASSWORD}"
echo " "
hostname