-
Notifications
You must be signed in to change notification settings - Fork 0
/
useradd.sh
executable file
·53 lines (29 loc) · 998 Bytes
/
useradd.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
if [ $UID -ne 0 ] ; then
echo " 403 Error !!. Please run me as root"
exit
fi
echo "Creating a New User...."
echo -e " \n\n\n "
echo " Please enter the name of user: "
# Take input from user
read usr_name
# Make a new user and set his Password
useradd $usr_name -d /var/www/html/ -s /bin/bash
chown -R $usr_name:$usr_name /var/www/html/
echo "$usr_name:$usr_name-123#@"|chpasswd
# Enable SSH login
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
service ssh restart
echo -e "\n\n\n\n\n\n"
echo -e "\n\n\n\n\n\n"
echo "SSH via Password Authentication enabled"
echo "$usr_name ALL=NOPASSWD:ALL #Sudo rights for $usr_name " >>/etc/sudoers
echo "Sudo rights to $usr_name has been been provided with NOPASSWD Authentication"
echo -e "\n\n\n\n\n\n"
echo "Synchronizing System Time"
apt-get install -y ntp
echo -e "\n\n\n\n\n\n"
echo -e "\n\n\n\n\n\n"
#install postfix
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix