Skip to content
DevOps & Tools⏱️ 10 min read·

How to Configure Git, GitHub, and SSH Keys for a New Project (No Password Prompts)

Generate and configure ed25519 SSH keys for GitHub, clone and push private repositories without typing passwords, and fix 'Permission denied (publickey)' errors.

MN
Manoj NeupaneSoftware Developer & Programming Instructor
#Git#GitHub#SSH#Linux#DevOps
🎯 Who This Tutorial Is For

Developers frustrated by password deprecation on GitHub and wanting seamless, secure SSH-authenticated Git workflows.

📋 Prerequisites
  • ✓Git installed locally
  • ✓A free GitHub account

🚀 What You Will Learn & Build

  • ▸Why GitHub deprecated account password authentication
  • ▸Generating modern, secure Ed25519 SSH keys
  • ▸Adding public keys to GitHub and configuring ssh-agent
  • ▸Fixing 'Permission denied (publickey)' errors
1

1. Generating an Ed25519 SSH Key Pair

Run this in your terminal (macOS, Linux, or Git Bash on Windows):
Terminal
# 1. Generate modern Ed25519 key (replace with your GitHub email)
ssh-keygen -t ed25519 -C "your_email@example.com"

# Press Enter to save in default file (~/.ssh/id_ed25519)
# Optionally enter a passphrase

# 2. Start the ssh-agent in the background
eval "$(ssh-agent -s)"

# 3. Add private key to agent
ssh-add ~/.ssh/id_ed25519

# 4. Copy public key to clipboard
# On macOS:
pbcopy < ~/.ssh/id_ed25519.pub
# On Linux:
cat ~/.ssh/id_ed25519.pub
# On Windows Git Bash:
clip < ~/.ssh/id_ed25519.pub
2

2. Adding Your Key to GitHub Settings

1. In GitHub, click your profile icon in top-right → **Settings**. 2. In the left sidebar, click **SSH and GPG keys**. 3. Click **New SSH key**. 4. Give it a title (e.g. `M1 MacBook` or `Work Laptop`). 5. Paste your copied key starting with `ssh-ed25519 ...` and click **Add SSH key**.
3

3. Testing Authentication

Run this terminal command: ```bash ssh -T git@github.com ``` If successful, GitHub will reply: `Hi username! You've successfully authenticated, but GitHub does not provide shell access.`

✨ Expected Output & Verification

Running 'git push origin main' pushes your commits instantly without prompting for passwords or personal access tokens.

🧪 How to Test the Implementation

  1. 1Run `ssh -T git@github.com` and ensure it welcomes you by username
  2. 2Change remote URL from HTTPS to SSH: `git remote set-url origin git@github.com:username/repo.git`

⚠️ Common Errors & How to Fix Them

❌Permission denied (publickey)

Root Cause: Private key not added to ssh-agent, or uploaded the private key instead of the .pub public key.

Fix: Run `ssh-add ~/.ssh/id_ed25519` and verify you pasted the contents of `id_ed25519.pub` into GitHub.

🛡️ Security Considerations & Best Practices

  • !Never share or commit files named id_ed25519 (without .pub); that is your private key.

❓ Frequently Asked Questions (FAQ)

No, best security practice is to generate a distinct SSH key pair on each computer and add each public key to GitHub individually.

📌 Summary of Key Takeaways

  • ✓Use Ed25519 keys for speed and modern security.
  • ✓Add public key to GitHub; keep private key secret.

Official References & Further Reading