Last active
May 2, 2023 13:32
-
-
Save vinayakg/0153e8de9b02f064637b569d2e10ebe4 to your computer and use it in GitHub Desktop.
Create User debian
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
useradd -m -d /home/pivg -s /bin/bash pivg | |
passwd pivg | |
cp -r .ssh /home/pivg/ | |
# ensure the directory ir owned by the new user | |
chown -R pivg:pivg /home/pivg/.ssh | |
# make sure only the new user has permissions | |
chmod 700 /home/pivg/.ssh | |
chmod 600 /home/pivg/.ssh/authorized_keys | |
usermod -aG sudo pivg | |
# https://humanwhocodes.com/snippets/2021/03/create-user-linux-ssh-key/ | |
# Automatically upgrade apt packages | |
sudo apt update && sudo apt upgrade -y | |
# Install unattended upgrades | |
sudo apt install unattended-upgrades -y | |
# Enable auto updates for unattended upgrades | |
echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | sudo debconf-set-selections | |
# Prevent SSH brute force attacks by installing fail2ban | |
sudo apt install fail2ban -y | |
# Install firewall ufw | |
sudo apt install ufw -y | |
# Rate limit SSH attempts | |
sudo ufw limit ssh/tcp | |
# Firewall rules | |
sudo ufw allow OpenSSH | |
sudo ufw allow dns | |
sudo ufw allow http | |
sudo ufw allow https | |
# Enable ufw and default to deny | |
sudo ufw enable | |
sudo ufw default deny incoming | |
sudo ufw default allow outgoing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment