# Generate a 4096‑bit RSA key (adjust algorithm if you prefer Ed25519)
ssh-keygen -t rsa -b 4096 -C "admin@myserver"
# Copy the public key to the remote host (replace user and host as needed)
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
# Generate a 4096‑bit RSA key (adjust algorithm if you prefer Ed25519)
ssh-keygen -t rsa -b 4096 -C "admin@myserver"
# Copy the public key to the remote host (replace user and host as needed)
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
# Generate a 4096‑bit RSA key (adjust algorithm if you prefer Ed25519)
ssh-keygen -t rsa -b 4096 -C "admin@myserver"
# Copy the public key to the remote host (replace user and host as needed)
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
ssh [email protected]
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
ssh [email protected]
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
ssh [email protected]
# Install ufw (Debian/Ubuntu) or use the built‑in package on most distros
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install ufw -y
# Default deny inbound, allow all outbound
-weight: 600;">sudo ufw default deny incoming
-weight: 600;">sudo ufw default allow outgoing
# Allow SSH from a trusted subnet (replace 203.0.113.0/24 with your network)
-weight: 600;">sudo ufw allow from 203.0.113.0/24 to any port 22 proto tcp
# If the server hosts a web site, open HTTP/HTTPS
-weight: 600;">sudo ufw allow 80/tcp
-weight: 600;">sudo ufw allow 443/tcp
# Enable the firewall
-weight: 600;">sudo ufw -weight: 500;">enable
# Install ufw (Debian/Ubuntu) or use the built‑in package on most distros
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install ufw -y
# Default deny inbound, allow all outbound
-weight: 600;">sudo ufw default deny incoming
-weight: 600;">sudo ufw default allow outgoing
# Allow SSH from a trusted subnet (replace 203.0.113.0/24 with your network)
-weight: 600;">sudo ufw allow from 203.0.113.0/24 to any port 22 proto tcp
# If the server hosts a web site, open HTTP/HTTPS
-weight: 600;">sudo ufw allow 80/tcp
-weight: 600;">sudo ufw allow 443/tcp
# Enable the firewall
-weight: 600;">sudo ufw -weight: 500;">enable
# Install ufw (Debian/Ubuntu) or use the built‑in package on most distros
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install ufw -y
# Default deny inbound, allow all outbound
-weight: 600;">sudo ufw default deny incoming
-weight: 600;">sudo ufw default allow outgoing
# Allow SSH from a trusted subnet (replace 203.0.113.0/24 with your network)
-weight: 600;">sudo ufw allow from 203.0.113.0/24 to any port 22 proto tcp
# If the server hosts a web site, open HTTP/HTTPS
-weight: 600;">sudo ufw allow 80/tcp
-weight: 600;">sudo ufw allow 443/tcp
# Enable the firewall
-weight: 600;">sudo ufw -weight: 500;">enable
# Install Fail2Ban (most distributions)
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install fail2ban -y
# Create a local jail file to avoid overwriting defaults on -weight: 500;">upgrade
-weight: 600;">sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# Edit /etc/fail2ban/jail.local and -weight: 500;">enable the sshd section
[sshd]
enabled = true
port = ssh
logpath = %(sshd_log)s
maxretry = 5
bantime = 3600
findtime = 600
# Install Fail2Ban (most distributions)
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install fail2ban -y
# Create a local jail file to avoid overwriting defaults on -weight: 500;">upgrade
-weight: 600;">sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# Edit /etc/fail2ban/jail.local and -weight: 500;">enable the sshd section
[sshd]
enabled = true
port = ssh
logpath = %(sshd_log)s
maxretry = 5
bantime = 3600
findtime = 600
# Install Fail2Ban (most distributions)
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install fail2ban -y
# Create a local jail file to avoid overwriting defaults on -weight: 500;">upgrade
-weight: 600;">sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# Edit /etc/fail2ban/jail.local and -weight: 500;">enable the sshd section
[sshd]
enabled = true
port = ssh
logpath = %(sshd_log)s
maxretry = 5
bantime = 3600
findtime = 600
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart fail2ban
# Verify the jail is active
-weight: 600;">sudo fail2ban-client -weight: 500;">status sshd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart fail2ban
# Verify the jail is active
-weight: 600;">sudo fail2ban-client -weight: 500;">status sshd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart fail2ban
# Verify the jail is active
-weight: 600;">sudo fail2ban-client -weight: 500;">status sshd
# Debian/Ubuntu: -weight: 500;">install the package
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install unattended-upgrades -weight: 500;">apt-listchanges -y
# Enable automatic installation of security updates
-weight: 600;">sudo dpkg-reconfigure --priority=low unattended-upgrades
# Optional: edit /etc/-weight: 500;">apt/-weight: 500;">apt.conf.d/50unattended-upgrades to fine‑tune
# Example snippet – -weight: 500;">enable only security repos
Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-security";
};
# Set a daily reboot if a kernel -weight: 500;">update occurs (optional)
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
# Debian/Ubuntu: -weight: 500;">install the package
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install unattended-upgrades -weight: 500;">apt-listchanges -y
# Enable automatic installation of security updates
-weight: 600;">sudo dpkg-reconfigure --priority=low unattended-upgrades
# Optional: edit /etc/-weight: 500;">apt/-weight: 500;">apt.conf.d/50unattended-upgrades to fine‑tune
# Example snippet – -weight: 500;">enable only security repos
Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-security";
};
# Set a daily reboot if a kernel -weight: 500;">update occurs (optional)
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
# Debian/Ubuntu: -weight: 500;">install the package
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install unattended-upgrades -weight: 500;">apt-listchanges -y
# Enable automatic installation of security updates
-weight: 600;">sudo dpkg-reconfigure --priority=low unattended-upgrades
# Optional: edit /etc/-weight: 500;">apt/-weight: 500;">apt.conf.d/50unattended-upgrades to fine‑tune
# Example snippet – -weight: 500;">enable only security repos
Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-security";
};
# Set a daily reboot if a kernel -weight: 500;">update occurs (optional)
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
-weight: 600;">sudo -weight: 500;">dnf -weight: 500;">install -weight: 500;">dnf-automatic -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable --now -weight: 500;">dnf-automatic.timer
# Review /etc/-weight: 500;">dnf/automatic.conf to restrict to security updates only
-weight: 600;">sudo -weight: 500;">dnf -weight: 500;">install -weight: 500;">dnf-automatic -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable --now -weight: 500;">dnf-automatic.timer
# Review /etc/-weight: 500;">dnf/automatic.conf to restrict to security updates only
-weight: 600;">sudo -weight: 500;">dnf -weight: 500;">install -weight: 500;">dnf-automatic -y
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable --now -weight: 500;">dnf-automatic.timer
# Review /etc/-weight: 500;">dnf/automatic.conf to restrict to security updates only