A Painless Guide to Setting Up SSH for Servers & GitHub (No More Passwords!)
Let’s be honest—typing passwords over and over is annoying. Worse, it’s not the most secure way to work with servers or GitHub.
Enter SSH keys: your ticket to password-free logins and secure connections.
In this guide, I’ll walk you through setting up SSH for:
🔑 Accessing a remote server without typing a password
💻 Connecting to GitHub securely (no more annoying HTTPS auth popups!)
No fluff—just clear, step-by-step instructions. Let’s get you set up in under 10 minutes.
What You’ll Need
✔ A computer (Linux, Mac, or Windows with WSL/Git Bash)
✔ A terminal (yes, that scary black box—we’ll make it easy)
✔ A remote server (if you want SSH access)
✔ A GitHub account (for Git operations)
Step 1: Create Your SSH Key (The Magic Key to Everything)
Open your terminal and run:
ssh-keygen -t ed25519 -C "your_email@example.com"
(If your system doesn’t support ed25519
, use -t rsa -b 4096
instead.)
You’ll see:
Generating public/private ed25519 key pair. Enter file in which to save the key (/home/you/.ssh/id_ed25519): [Press Enter] Enter passphrase (empty for no passphrase): [Optional, but recommended]
💡 Pro Tip:
Just hit Enter to save in the default location.
A passphrase adds extra security (like a password for your key).
Step 2: Wake Up the SSH Agent (The Key Manager)
Your SSH key won’t work unless the SSH agent knows about it. Run:
eval "$(ssh-agent -s)" # Starts the agent ssh-add ~/.ssh/id_ed25519 # Adds your key
(If you used RSA, replace id_ed25519
with id_rsa
.)
Step 3: Connect to a Remote Server (No Password Needed!)
Option A: The Easy Way (ssh-copy-id
)
If your system has ssh-copy-id
, this is a one-liner:
ssh-copy-id username@your_server_ip
It’ll ask for your server password once, then never again!
Option B: Manual Setup (If ssh-copy-id
Fails)
Copy your public key:
cat ~/.ssh/id_ed25519.pub
Log in to your server (the old way, with a password):
ssh username@your_server_ip
Paste your key into
~/.ssh/authorized_keys
:mkdir -p ~/.ssh echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
Now, try logging in again—no password needed!
ssh username@your_server_ip
🎉 Success! You’ve just eliminated password headaches forever.
Step 4: Connect GitHub with SSH (Goodbye, HTTPS Auth Errors!)
1. Grab Your Public Key
Run this and copy the output:
cat ~/.ssh/id_ed25519.pub
(Windows? Use clip < ~/.ssh/id_ed25519.pub
to copy to clipboard.)
2. Add It to GitHub
Click New SSH Key
Paste your key and save
3. Test It
Run:
ssh -T git@github.com
You should see:
Hi username! You’ve successfully authenticated…
Step 5: Clone a Repo Using SSH (Faster & More Secure)
Instead of:
git clone https://github.com/user/repo.git # Asks for password every time!
Use:
git clone git@github.com:user/repo.git # No passwords, ever!
🚀 Now you can git push
without typing credentials!
Troubleshooting: Common SSH Issues
🔴 “Permission denied (publickey)”
👉 Fix:
Make sure your public key is in
~/.ssh/authorized_keys
on the server.Set correct permissions:
chmod 600 ~/.ssh/id_ed25519
🔴 GitHub SSH not working?
👉 Try:
ssh-add -D && ssh-add ~/.ssh/id_ed25519 # Resets and reloads your key
Final Thoughts
You’ve just:
✔ Ditched passwords for secure SSH keys
✔ Made server logins effortless
✔ Stopped GitHub from bugging you for credentials
Next steps?
Use
scp
orrsync
for secure file transfers.Set up multiple SSH keys for different services.
Stuck? Drop a comment—I’ll help! 👇
Why This Matters for Security & Convenience
🔐 More secure than passwords (no brute-force attacks)
⚡ Faster logins (no typing passwords repeatedly)
🤖 Automation-friendly (great for scripts & CI/CD)
Now go enjoy your password-free workflow! 🎉