-
Notifications
You must be signed in to change notification settings - Fork 39
/
startup.sh
63 lines (47 loc) · 1.69 KB
/
startup.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
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
### SETTINGS ->
KEY="ssh-rsa ABC123== [email protected]" # Please, place below your public key!
TIMEZONE="Australia/Sydney" # Change to your timezone
### <- SETTINGS
# Create admin user
adduser --disabled-password --gecos "Admin" admin
# Setup admin password
echo admin:`openssl rand -base64 32` | chpasswd
# Allow sudo for admin
echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Setup SSH keys
mkdir -p /home/admin/.ssh/
echo $KEY > /home/admin/.ssh/authorized_keys
chmod 700 /home/admin/.ssh/
chmod 600 /home/admin/.ssh/authorized_keys
chown -R admin:admin /home/admin/.ssh
# Disable password login for this user
# Optional
echo "PasswordAuthentication no" | tee --append /etc/ssh/sshd_config
# Reload SSH changes
systemctl reload sshd
# Fix environment
echo 'LC_ALL="en_US.UTF-8"' >> /etc/environment
# Essentials
apt-get dist-upgrade ; apt-get -y update ; apt-get -y upgrade
apt-get -y install unattended-upgrades software-properties-common apache2-utils fail2ban
apt-get -y install mc htop
# Trash-cli
apt-get -y install trash-cli
echo "alias rm='echo \"This is not the command you are looking for. Use <trash> instead.\"; false'" >> /etc/bash.bashrc
# Install security updates automatically
echo -e "APT::Periodic::Update-Package-Lists \"1\";\nAPT::Periodic::Unattended-Upgrade \"1\";\nUnattended-Upgrade::Automatic-Reboot \"false\";\n" > /etc/apt/apt.conf.d/20auto-upgrades
/etc/init.d/unattended-upgrades restart
# Change the timezone
echo $TIMEZONE > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Setup simple Firewall
ufw allow 22 #OpenSSH
ufw allow 80 #http
ufw allow 443 #https
yes | ufw enable
# Check Firewall settings
ufw status
# See disk space
df -h
rm ./startup.sh