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.
๐ Try it out: Compare the difference between password login and key login๐ Try it out: Compare the difference between password login and key login
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).
------
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 Key | Public Key | |
|---|---|---|
| Stored on | Your computer ~/.ssh/id_ed25519 | Server / GitHub |
| Can you share it? | โ Never | โ Share freely |
| Function | Sign (prove identity) | Verify signature (confirm identity) |
| Analogy | Key | Lock |
| Type | Command | Recommendation | Notes |
|---|---|---|---|
| Ed25519 | ssh-keygen -t ed25519 | โญโญโญ | Newest, fastest, most secure |
| RSA | ssh-keygen -t rsa -b 4096 | โญโญ | Good compatibility, but slower |
| ECDSA | ssh-keygen -t ecdsa | โญ | Generally not recommended |
------
bash ssh-keygen -t ed25519 -C "your@email.com"
After running, you'll be prompted for:After running, you'll be prompted for:
~/.ssh/id_ed25519File path: Press Enter to use the default path ~/.ssh/id_ed25519bash # 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...
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"
------
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:
| Before | After |
|---|---|
ssh -i ~/.ssh/id_ed25519 deploy@192.168.1.100 | ssh dev |
| Memorize IP and username every time | Just remember one alias |
------
| Problem | Cause | Solution |
|---|---|---|
Permission denied (publickey) | Public key not added to server | ssh-copy-id user@server |
WARNING: UNPROTECTED PRIVATE KEY FILE | Private key file permissions too broad | chmod 600 ~/.ssh/id_ed25519 |
Could not resolve hostname | SSH Config misconfigured | Check ~/.ssh/config format |
| GitHub still asks for password | Using HTTPS instead of SSH | Switch to git@github.com:user/repo.git |
------
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: