Managing SSH keys: adding and removing

12.03.2026
Complexity
min.

Summary

SSH keys allow passwordless server login and improve security. Below: how to generate a key, add it to the server, and disable password login.

Applies to:
✔ VPS
✔ Dedicated servers
✔ Linux, macOS, Windows

Generating a key

Linux/macOS

ssh-keygen -t ed25519 -C "your@email.com"

Or RSA:

ssh-keygen -t rsa -b 4096

Windows (PowerShell)

ssh-keygen -t ed25519

Adding the key to the server

Automatically

ssh-copy-id -i ~/.ssh/id_ed25519.pub root@SERVER_IP

Manually

cat ~/.ssh/id_ed25519.pub
mkdir -p /root/.ssh
echo "PUBLIC_KEY_CONTENT" >> /root/.ssh/authorized_keys
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys

Removing a key

Edit authorized_keys on the server and remove the line with the unwanted key:

nano /root/.ssh/authorized_keys

Disabling password login

Before disabling passwords, make sure key-based login works! Otherwise you'll lose server access.

In /etc/ssh/sshd_config:

PasswordAuthentication no
PubkeyAuthentication yes
systemctl restart sshd

Verification

ssh root@SERVER_IP

Should connect without a password prompt.

If key login doesn't work, check permissions on ~/.ssh (700) and authorized_keys (600). If locked out, connect via VNC/IPMI console.
Was this information helpful?
Yes   No
 
By continuing to use this website you will be agreeing to the website Acceptable Use Policy and the Use of Cookies while using the website and our services. Please also read our Privacy Policy under which, to the extent stated, you consent to the processing of your personal data.