VPS SSH Hardening Guide

Complete procedure for transitioning from passwords to secure SSH keys.

Security Status: Hardened
1

Generate SSH Key Pair

On your local computer (e.g., in MobaXterm MobaKeyGen), generate an RSA 2048-bit key. Set a passphrase for maximum security.

Important: Save your .ppk private key file in a safe location. Never share it.
2

Install Public Key on VPS

Prepare the hidden directory and paste your OpenSSH formatted public key string.

mkdir -p ~/.ssh && chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys

Paste the ssh-rsa ... string on a single line, then save and exit (Ctrl+O, Enter, Ctrl+X).

chmod 600 ~/.ssh/authorized_keys
3

Disable Password Authentication

Tell the SSH daemon to stop listening to password attempts entirely.

sudo nano /etc/ssh/sshd_config

Ensure these values are set exactly as shown (uncommented):

PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no

Apply the changes by restarting the service:

sudo systemctl restart ssh
!

Verification Checklist

Do not close your terminal until you confirm these two things: