-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path01-initial-setup.sh
41 lines (32 loc) · 1.22 KB
/
01-initial-setup.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
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
if [[ -z "$1" ]]
then echo "You must provide a username to create"
exit
fi
if [[ "$2" = "NOPASSWD" ]]
then SUDOERS="$1 ALL=(ALL:ALL) NOPASSWD:ALL"
else SUDOERS="$1 ALL=(ALL:ALL) ALL"
fi
echo '.___ .__ __ .__ .__ _________ __ '
echo '| | ____ |__|/ |_|__|____ | | / _____/ _____/ |_ __ ________ '
echo '| |/ \| \ __\ \__ \ | | \_____ \_/ __ \ __\ | \____ \ '
echo '| | | \ || | | |/ __ \| |__ / \ ___/| | | | / |_> >'
echo '|___|___| /__||__| |__(____ /____/ /_______ /\___ >__| |____/| __/ '
echo ' \/ \/ \/ \/ |__| '
# Perform system update and upgrade and install ntp
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
apt-get install ntp -y
# Configure timezone
dpkg-reconfigure tzdata
# Add new user and put this user to sudoers.d
adduser $1
echo $SUDOERS >> /etc/sudoers.d/$1
chmod 440 /etc/sudoers.d/$1
# Deny user root for ssh login
sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
# Restart SSH service
service ssh restart