Last active
April 27, 2024 14:26
-
-
Save gtrabanco/1d81a9129cee29c5fdb3639b67bd7603 to your computer and use it in GitHub Desktop.
Initial setup for ubuntu/debian server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if ! command -p sudo -n -v > /dev/null 2>&1; then | |
echo "Execute this script as admin by using sudo writing:" | |
echo " sudo !!" | |
echo | |
fi | |
# Update | |
apt update -y | |
apt upgrade -y | |
apt dist-upgrade -y | |
#Vim | |
apt install -y vim | |
# Unnatended upgrades | |
apt install -y unattended-upgrades | |
# Firewall | |
apt install -y iptables-persistent ufw | |
ufw allow ssh | |
ufw enable | |
# Minimal firewall rules if no ufw installed | |
#iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | |
#iptables -P INPUT DROP | |
#ip6tables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | |
#ip6tables -P INPUT DROP | |
# Save firewall rules | |
iptables-save | tee /etc/iptables/rules.v4 | |
ip6tables-save | tee /etc/iptables/rules.v6 | |
# Remove unnecessary stuff | |
apt autoremove --purge # This will cleanup also old kernels, maybe you should do this as well after reboot. Maybe there was an installtion of new kernel when updating... | |
apt autoclean | |
apt clean | |
# Check apt cache is empty (12K is empty) | |
du -sh /var/cache/apt |
Author
gtrabanco
commented
Apr 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment