Stop Using Password Login! Use SSH Keys Instead

Stop Using Password Login! Use SSH Keys Instead

Passwords are one of the weakest links in server security. They can be guessed, leaked, or brute-forced.

If you're still logging into your server using a password… it’s time to stop.

👉 The solution? SSH Keys

Why You Should Stop Using Passwords

Password-based login has several risks:

  • ❌ Weak passwords can be guessed
  • ❌ Vulnerable to brute-force attacks
  • ❌ Can be leaked or reused
  • ❌ Hard to manage securely at scale

Attackers constantly scan servers trying to log in using common passwords.

What Are SSH Keys?

SSH keys are a secure authentication method using cryptography.

They come in two parts:

  • Private Key → stays on your computer (keep it secret!)
  • Public Key → stored on the server

👉 Instead of typing a password, your system proves identity using the key.

Step 1: Generate SSH Key Pair

Run this command on your local machine:

ssh-keygen -t ed25519 -C "your_email@example.com"

Press Enter to accept defaults.

📁 Keys will be created in:

~/.ssh/id_ed25519 (Private Key)
~/.ssh/id_ed25519.pub (Public Key)

Step 2: Copy Public Key to Server

Use this command:

ssh-copy-id username@your_server_ip

Or manually:

cat ~/.ssh/id_ed25519.pub

Then paste into server file:

~/.ssh/authorized_keys

Step 3: Login Using SSH Key

Now try:

ssh username@your_server_ip

✅ You should log in without a password

Step 4: Disable Password Authentication

⚠️ Important: Only do this AFTER confirming SSH key login works!

Edit SSH config:

sudo nano /etc/ssh/sshd_config

Find and change:

PasswordAuthentication no

(Optional but recommended):

PermitRootLogin no

Step 5: Restart SSH Service

sudo systemctl restart ssh

Extra Security Tips

  • 🔒 Use a passphrase for your private key
  • 🧱 Change default SSH port (22 → custom)
  • 🚫 Use firewall (UFW / iptables)
  • 🔍 Install fail2ban to block attackers

SSH Keys vs Passwords

FeaturePassword 🔑SSH Key 🔐
SecurityLowHigh
Brute-forcePossibleNearly impossible
ConvenienceMediumHigh
AutomationHardEasy

Conclusion

Stop relying on outdated password authentication.

👉 SSH keys provide:

  • Strong security
  • Faster login
  • Better automation

If you're serious about server security, SSH keys are a must.

Souy Soeng

Souy Soeng

Hi there 👋, I’m Soeng Souy (StarCode Kh)
-------------------------------------------
🌱 I’m currently creating a sample Laravel and React Vue Livewire
👯 I’m looking to collaborate on open-source PHP & JavaScript projects
💬 Ask me about Laravel, MySQL, or Flutter
⚡ Fun fact: I love turning ☕️ into code!

Post a Comment

CAN FEEDBACK
close