Security & Firewalls Beginner 10 min

How to Configure SSH Key Authentication & Disable Password Login

Eliminate 99.9% of automated brute-force attacks by requiring cryptographic SSH keys for all logins

IndSoft Cloud Engineering
Reviewed October 2026
Production Verified Commands

Guide Overview & Architecture Outcome

By following this guide, you will generate an ultra-secure Ed25519 SSH keypair on your local computer, install it onto your Linux server, and disable root password logins to completely neutralize dictionary attacks.

Prerequisites & System Requirements

Any Linux server running OpenSSH server. Recommended for all newly provisioned IndSoft VPS instances.

1

Generate an Ed25519 Keypair on Your Local Computer

Run ssh-keygen locally using the modern, high-speed Ed25519 elliptic curve algorithm.

bash · step-1-command.sh
ssh-keygen -t ed25519 -C "admin@example.com"
Expected System Output:
Your identification has been saved in id_ed25519 Your public key has been saved in id_ed25519.pub
2

Copy Public Key to Your Remote Server

Use ssh-copy-id to append your public key to ~/.ssh/authorized_keys on the server.

bash · step-2-command.sh
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@YOUR_SERVER_IP
Expected System Output:
Number of key(s) added: 1 Now try logging into the machine.
3

Disable Password Authentication in sshd_config

Once key login is verified, disable password authentication and direct root login.

bash · step-3-command.sh
sudo nano /etc/ssh/sshd_config # Set: PasswordAuthentication no # Set: PermitRootLogin prohibit-password # Set: PubkeyAuthentication yes sudo systemctl restart ssh
Expected System Output:
SSH daemon reloaded.

Check That It Worked (Verification)

Run this quick verification check to confirm your installation is responding properly:

verify-service.sh
ssh -o PasswordAuthentication=no user@YOUR_SERVER_IP
Expected Response:
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-31-generic x86_64) - Authentication succeeded without password prompt.

Troubleshooting Common Errors

Quick resolutions for frequent setup pitfalls and configuration issues.

Diagnostic Tips
Locked out after disabling passwords
Do NOT close your active SSH terminal until you have verified logging in from a second terminal window. If locked out, use the IndSoft VNC Web Console in the Client Portal to restore PasswordAuthentication yes.
Permission denied (publickey)
Ensure the permissions on the server are correct: chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys.
Changes not taking effect
On Ubuntu 22.04/24.04, check /etc/ssh/sshd_config.d/ for drop-in configuration files that may override the main sshd_config.