VibeKoding / Ensiklopedia ยท Fondasi KuatEnsiklopedia ยท Fondasi Kuat / An Introduction to SSH and Key AuthenticationAn Introduction to SSH and Key Authentication
VK

An Introduction to SSH and Key AuthenticationAn Introduction to SSH and Key Authentication

๐Ÿ“š Ensiklopedia ยท Fondasi KuatEnsiklopedia ยท Fondasi Kuat ๐ŸŒ Dual Bahasa (ID / EN) โšก VibeKoding Native

Ensiklopedia VibeKoding: An Introduction to SSH and Key Authentication.Ensiklopedia VibeKoding: An Introduction to SSH and Key Authentication.

> ๐Ÿ’ก Learning Guide: Tired of entering your password every time you git push? Getting "Permission denied" when connecting to a server? This chapter takes 5 minutes to explain how SSH key authentication works and how to set up password-free login to GitHub and servers with a single command.> ๐Ÿ’ก Learning Guide: Tired of entering your password every time you git push? Getting "Permission denied" when connecting to a server? This chapter takes 5 minutes to explain how SSH key authentication works and how to set up password-free login to GitHub and servers with a single command.

1. Password vs. Key: Why Keys Are Better1. Password vs. Key: Why Keys Are Better

๐Ÿ‘‡ Try it out: Compare the difference between password login and key login๐Ÿ‘‡ Try it out: Compare the difference between password login and key login

๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

Password login = sending the password each time for the other side to verify (the password could be intercepted); Key login = proving "I have the key" without showing the key to anyone (the private key is never transmitted).Password login = sending the password each time for the other side to verify (the password could be intercepted); Key login = proving "I have the key" without showing the key to anyone (the private key is never transmitted).

------

2. Asymmetric Encryption: Public Key and Private Key2. Asymmetric Encryption: Public Key and Private Key

SSH keys are based on asymmetric encryption, generating two keys at once:SSH keys are based on asymmetric encryption, generating two keys at once:

Private KeyPublic Key
Stored onYour computer ~/.ssh/id_ed25519Server / GitHub
Can you share it?โŒ Neverโœ… Share freely
FunctionSign (prove identity)Verify signature (confirm identity)
AnalogyKeyLock

Common Key TypesCommon Key Types

TypeCommandRecommendationNotes
Ed25519ssh-keygen -t ed25519โญโญโญNewest, fastest, most secure
RSAssh-keygen -t rsa -b 4096โญโญGood compatibility, but slower
ECDSAssh-keygen -t ecdsaโญGenerally not recommended

------

3. Hands-on: Generating and Configuring SSH Keys3. Hands-on: Generating and Configuring SSH Keys

3.1 Generate a Key Pair3.1 Generate a Key Pair

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

After running, you'll be prompted for:After running, you'll be prompted for:

3.2 Add the Public Key to GitHub3.2 Add the Public Key to GitHub

bash
# 1. Copy the public key content cat ~/.ssh/id_ed25519.pub | pbcopy # macOS cat ~/.ssh/id_ed25519.pub | xclip # Linux # 2. Open GitHub โ†’ Settings โ†’ SSH and GPG keys โ†’ New SSH key # 3. Paste the public key and save # 4. Test the connection ssh -T git@github.com # Success message: Hi username! You've been authenticated...

3.3 Add the Public Key to a Server3.3 Add the Public Key to a Server

bash
# Method 1: ssh-copy-id (recommended) ssh-copy-id user@your-server # Method 2: Manual copy cat ~/.ssh/id_ed25519.pub | ssh user@server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

------

4. SSH Config: Say Goodbye to Long Commands4. SSH Config: Say Goodbye to Long Commands

Configure aliases in ~/.ssh/config โ€” set it up once and benefit forever:Configure aliases in ~/.ssh/config โ€” set it up once and benefit forever:

CODE
Host dev HostName 192.168.1.100 User deploy IdentityFile ~/.ssh/id_ed25519 Host github.com HostName github.com User git IdentityFile ~/.ssh/id_ed25519

After configuration:After configuration:

BeforeAfter
ssh -i ~/.ssh/id_ed25519 deploy@192.168.1.100ssh dev
Memorize IP and username every timeJust remember one alias

------

5. Common Issue Troubleshooting5. Common Issue Troubleshooting

ProblemCauseSolution
Permission denied (publickey)Public key not added to serverssh-copy-id user@server
WARNING: UNPROTECTED PRIVATE KEY FILEPrivate key file permissions too broadchmod 600 ~/.ssh/id_ed25519
Could not resolve hostnameSSH Config misconfiguredCheck ~/.ssh/config format
GitHub still asks for passwordUsing HTTPS instead of SSHSwitch to git@github.com:user/repo.git

------

6. Summary6. Summary

๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

1. Keys > Passwords: Private keys are never transmitted, making them far more secure than passwords 2. Ed25519 recommended: The most modern key algorithm โ€” fast and highly secure 3. Share public keys freely, never leak private keys: Remember this golden rule 4. SSH Config: Set up aliases once, then ssh alias connects instantly 5. GitHub/GitLab: After adding your public key, git push/pull never requires a password again1. Keys > Passwords: Private keys are never transmitted, making them far more secure than passwords 2. Ed25519 recommended: The most modern key algorithm โ€” fast and highly secure 3. Share public keys freely, never leak private keys: Remember this golden rule 4. SSH Config: Set up aliases once, then ssh alias connects instantly 5. GitHub/GitLab: After adding your public key, git push/pull never requires a password again

Next Steps:Next Steps: