Docs / Security / How to Set Up SSH Key Authentication

How to Set Up SSH Key Authentication

By Admin · Feb 25, 2026 · Updated Apr 24, 2026 · 416 views · 1 min read

SSH keys are more secure than passwords and prevent brute-force attacks.

Generate a Key Pair (on your local machine)

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

Copy the Public Key to Your Server

ssh-copy-id user@YOUR_IP_ADDRESS

Or manually:

cat ~/.ssh/id_ed25519.pub | ssh user@YOUR_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Disable Password Authentication

Edit /etc/ssh/sshd_config:

PasswordAuthentication no
PubkeyAuthentication yes
systemctl restart sshd

Key Types

  • Ed25519 — recommended, fast, secure
  • RSA 4096 — widely compatible
  • ECDSA — good alternative

Was this article helpful?