Password-based SSH authentication is one of the most common attack vectors for Linux servers. SSH key authentication eliminates this risk entirely while making your workflow faster and more convenient.
Why SSH Keys Are Superior to Passwords
SSH keys use asymmetric cryptography β a private key stays on your machine while the public key lives on the server. Even with millions of brute-force attempts, an attacker cannot guess your private key.
Generating Your SSH Key Pair
ssh-keygen -t ed25519 -C "admin@dargslan.com"
ssh-keygen -t rsa -b 4096 -C "admin@dargslan.com"
ls -la ~/.ssh/
Deploying Your Public Key
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server-ip
ssh user@server-ip
Hardening sshd_config
PasswordAuthentication no
PubkeyAuthentication yes
PermitRootLogin prohibit-password
MaxAuthTries 3
AllowUsers deploy admin
sudo systemctl restart sshd
SSH Config for Multiple Servers
Host production
HostName 192.168.1.100
User deploy
IdentityFile ~/.ssh/id_ed25519_prod
Host staging
HostName 192.168.1.101
User deploy
IdentityFile ~/.ssh/id_ed25519_staging
SSH Agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-add -l
For a comprehensive deep dive into Linux server security, check out our Security and Hardening eBook collection.