This week’s headlines left many people asking whether their servers are still safe, and whether SSH keys still work if AI can break encryption. This guide answers those questions in plain words first. Then it gives 12 steps to secure your Linux server, with the commands tested in our lab. It is written so that an intern or a business owner with one small server can follow it.

Short on time? Read “The short answer”, then do steps 1, 2, 3 and 5 today. The rest can follow this week.

The short answer

  • Nobody has shown that AI can break the SSH keys or HTTPS certificates in use today.
  • The NSA asked for a faster move to new “post-quantum” encryption. It also said the new AI findings are not an immediate and widespread threat.
  • Real attacks this year, including the AI-assisted ones, got in through old weaknesses: missing updates, passwords, exposed admin pages and keys left in files.
  • So the work that protects you is the basic work, done properly. The 12 steps below show how to secure your Linux server in that order.

The facts, question by question

Can AI break my SSH key now?

No public evidence says so. The largest RSA number anyone has factored in public has 896 bits, and normal keys have 2048 bits or more. The gap between those two is enormous. Our RSA-2048 fact-check has the details and sources.

Then why did the NSA warn everyone?

AI labs privately told the US government about new findings that affect some encryption. On 2 December the NSA told the owners of national security systems to speed up their move to post-quantum encryption. On the same day the NSA, CISA and the White House cyber office said these advances “do not present an immediate and widespread threat”. So the message is to start moving, calmly.

Which SSH key should I use?

Key typeVerdict today
Ed25519Use this for new keys
RSA, 3072 or 4096 bitsFine
RSA, 2048 bitsFine for now; replace when you next rotate keys
RSA, 1024 bitsReplace now
DSARemove; it is obsolete

One honest note: none of these key types is “quantum-safe”, and that includes Ed25519. OpenSSH says it will add post-quantum login keys in the future. However, login keys do not have the “record now, decrypt later” problem. What protects recorded sessions is the key exchange, and step 4 checks that.

Should I stop using SSH or switch off RSA?

No. Hurried changes lock people out and break integrations. Instead, replace weak keys, keep OpenSSH updated and follow the steps below.

What do AI-assisted attacks actually do?

They do the same things human attackers do, but faster and against more targets at once. CISA said this week that these tools do not change the techniques or the flaws attackers use. Microsoft described one case where an attacker reached three more servers within 13 minutes. So a hole that used to sit unnoticed for months may now be found in days. That makes speed of patching the thing to fix first.

How do I know if my server is at risk?

A server is at higher risk if any of these is true: it has not been updated in the last month, it accepts SSH passwords, it has user accounts nobody remembers, it has services open to the internet that only staff need, or it has passwords and API keys sitting in readable files. Each step below removes one of those, so by the end you will secure your Linux server against all five.

Before you secure your Linux server

  • Work only on servers you own or manage.
  • Take a backup or a snapshot first.
  • Keep one SSH session open the whole time. Test every SSH change from a second window before you close the first. This one habit prevents lockouts.
  • We ran the commands below on Ubuntu 24.04 in our lab on 4 December 2026. Other Linux versions differ slightly.

Step 1: update everything

Most break-ins this year used flaws that already had a fix. First, see how many updates are waiting:

sudo apt update
apt list --upgradable | wc -l

Our lab machine, left alone for a few weeks, printed:

92

That means about 91 packages had updates waiting (the first line is a header). Install them:

sudo apt full-upgrade

Then check whether the server needs a restart:

[ -f /var/run/reboot-required ] && cat /var/run/reboot-required || echo "no reboot-required file"

If it says a restart is required, plan one. A new kernel does nothing until the server reboots. This matters right now, because a kernel flaw disclosed this week lets some IPv6 traffic get past firewalls. Our Linux IPv6 firewall bypass post explains it.

Step 2: create an SSH key and log in with it

A key is a pair of files. The private file stays on your laptop and the public file goes on the server. Run this on your own laptop, not on the server:

ssh-keygen -t ed25519 -C "ravi@office-laptop"

In our lab it printed:

Generating public/private ed25519 key pair.
Your identification has been saved in k1
Your public key has been saved in k1.pub

Set a passphrase when it asks, so a stolen laptop does not mean a stolen key. Then copy the public key to the server (replace the user and address with yours):

ssh-copy-id user@your-server-ip

Now open a new window and log in. If it lets you in without asking for the server password, the key works.

Next, list the keys that can log in to an account on the server:

ssh-keygen -l -f ~/.ssh/authorized_keys

In our lab, where we planted an old key as a test:

256 SHA256:f2eIdik9Xaglm/DvBuSponYInE4MDtix0G2zNgLX4s4 ravi@office-laptop (ED25519)
1024 SHA256:IWEtc9HQxDR39BfMRcTCOYSWRG50zbX2g4PjVfjeKkY old-laptop-2017 (RSA)

The first number is the key size. The 1024-bit line is the kind to remove: delete that line from authorized_keys once its owner has a new key. Also remove any key whose owner you cannot name.

Step 3: switch off SSH passwords and root login

Passwords can be guessed, and bots try thousands every day. So once your key works, turn passwords off. Create the file /etc/ssh/sshd_config.d/50-hardening.conf with these lines:

PasswordAuthentication no
PermitRootLogin no
MaxAuthTries 3
X11Forwarding no

Then test the file before you apply it:

sudo sshd -t && echo "sshd -t OK"
sshd -t OK

If you see an error instead, fix the file first. Then reload SSH with sudo systemctl reload ssh, and confirm what the server really uses:

sudo sshd -T | grep -E "^(passwordauthentication|permitrootlogin|maxauthtries|x11forwarding)"

In our lab, before the change, passwordauthentication said yes. After it:

maxauthtries 3
permitrootlogin no
passwordauthentication no
x11forwarding no

Finally, log in from a second window before you close the first one. Our SSH hardening checklist covers the remaining settings.

Step 4: check the SSH key exchange

This is the part that deals with the post-quantum worry. The key exchange protects each session, so that traffic someone records today cannot be read later. This shows whether your SSH supports a post-quantum key exchange:

ssh -Q kex | grep -i -E "mlkem|sntrup"

On Ubuntu 24.04 (OpenSSH 9.6) our lab printed:

sntrup761x25519-sha512@openssh.com

Any output means you are covered, because OpenSSH has used a post-quantum key exchange by default since version 9.0. If the command prints nothing, your OpenSSH is older than 9.0, so update the operating system. Our post-quantum readiness check goes further and covers websites too.

Step 5: turn on a firewall

A firewall lets in only what you choose. On Ubuntu the simple tool is ufw. First see its state:

sudo ufw status
Status: inactive

Allow SSH before you switch the firewall on, or you will lock yourself out:

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw default deny incoming
sudo ufw enable

Leave out the 80 and 443 lines if the server does not run a website. We ran the allow rules in ufw’s test mode in the lab, and it answered “Rules updated”. We did not enable the firewall there, because the lab container does not allow it. Also set the same short list at your cloud provider’s firewall or security group, so you have two layers.

Step 6: block repeated login attempts

fail2ban watches the login log and blocks addresses that keep failing. Install it with sudo apt install fail2ban, then create /etc/fail2ban/jail.local:

[sshd]
enabled = true
maxretry = 5
findtime = 10m
bantime = 1h

Check the file and restart the service:

sudo fail2ban-client -t
sudo systemctl restart fail2ban

The check printed this in our lab:

OK: configuration test is successful

Our fail2ban guide shows how to read the bans.

Step 7: make security updates automatic

Nobody remembers to update every week, so let the server do it. Install the tool with sudo apt install unattended-upgrades and check that it is on:

cat /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

Both lines should end in “1”. Our unattended-upgrades guide adds email reports and an automatic reboot time.

Step 8: remove accounts nobody uses

Old accounts are open doors. This lists every account that can log in with a shell:

awk -F: '$7 !~ /(nologin|false|sync)$/ {print $1": "$7}' /etc/passwd

A shortened list from our lab, where we created two test users:

root: /bin/bash
ubuntu: /bin/bash
deploy: /bin/bash
oldintern: /bin/bash

You should be able to name the person or the job behind every line. Here, oldintern belongs to someone who has left, so lock it with sudo usermod -L -s /usr/sbin/nologin oldintern. Then see who has admin rights:

getent group sudo
sudo:x:27:ubuntu,deploy

Remove anyone who does not need it with sudo gpasswd -d username sudo. Our sudo access guide explains the sudoers files.

Step 9: know what is listening

Every program that listens on the network is a possible way in. List them:

sudo ss -tlnp

A shortened line from our lab:

LISTEN 0  128  0.0.0.0:22  0.0.0.0:*  users:(("sshd",pid=1666,fd=3))

0.0.0.0 means “reachable from anywhere”, and 127.0.0.1 means “only from this server”. A database on 0.0.0.0 is the usual mistake: change its config to listen on 127.0.0.1. Our open ports guide explains every column.

Step 10: get passwords and keys out of readable files

Attackers who get into an app go straight for its config files, because the database password and API keys are there. Find .env files that other users on the server can read:

find /var/www /home /opt -name ".env*" -perm /044 -exec ls -l {} \;

We ran the same search on a test folder in our lab with a planted file:

-rw-r--r-- ./config/.env

Fix each one so only its owner can read it:

chmod 600 /path/to/.env

After that the same file showed -rw-------. Also never put passwords in commands, because they stay in the shell history. Our exposed AWS keys guide shows how to search files and git history for keys.

Step 11: back up, and test the restore

A backup is the only real answer to ransomware and to your own mistakes. Keep three copies, on two kinds of storage, with one copy away from the server. A snapshot stored in the same account as the server does not count as “away”. Then, once a month, restore one file or one database from the backup. A backup you have never restored is only a hope, and no plan to secure your Linux server is complete without one.

Step 12: look at the server for ten minutes a week

Pick a day. Then run three checks: who logged in (last -n 20), what is listening (sudo ss -tlnp) and which sensitive files changed in the last week:

sudo find /etc/sudoers /etc/sudoers.d /etc/cron.d /etc/crontab /root/.ssh /home/*/.ssh -type f -mtime -7

Every line it prints should match a change you know about. Our hacked server checklist has ten commands for a deeper look.

If something looks wrong

Do not delete things in a hurry. First take a snapshot for evidence. Then cut the server off from the network, change every password and key that was stored on it, and rebuild from a clean backup if you cannot explain what you found. If customer data is involved, the CERT-In six-hour rule may apply. Our CERT-In reporting guide explains what to send.

The one-page checklist

  1. Updates installed, reboot done if needed
  2. SSH key created (Ed25519), old and unknown keys removed
  3. SSH passwords and root login off
  4. Post-quantum key exchange present (OpenSSH 9.0 or later)
  5. Firewall on, only needed ports open
  6. fail2ban running
  7. Automatic security updates on
  8. Unused accounts locked, sudo list short
  9. Nothing listening on 0.0.0.0 that only staff need
  10. Config files with secrets set to 600
  11. Backup tested with a restore
  12. Ten-minute weekly check in the calendar

Free check: our website safety check grades your site’s HTTPS and security headers from the outside in 30 seconds.

Related guides

Sources

Want a second pair of eyes on your servers? Our Linux server hardening audit reviews SSH, accounts, sudo rules, exposed services and permissions. The SSH Hardening Pack (₹99) has tested sshd_config drop-ins and a guided install script that refuses to lock you out.

Post author avatar

Bhaskar Soni

Bhaskar Soni is a Security Engineer and the founder of Youngster Company, based in Ahmedabad, Gujarat. He works hands-on with Linux server hardening, vulnerability assessment and penetration testing (VAPT), ISO 27001 compliance and OSINT investigations. He writes practical, tested guides for IT professionals and Indian businesses, and every article on this site is written or reviewed by him.

Leave a Reply