Class 25 of 50 • Remote Collaboration

Git SSH Authentication: Generating ed25519 Keys and Configuring GitHub

In August 2021, GitHub permanently deprecated account password authentication for Git operations. Today, professional developers authenticate via SSH (Secure Shell) Key Pairs. SSH provides superior cryptographic security and enables passwordless, seamless pushing and pulling from your terminal.

How SSH Public-Key Cryptography Works

SSH authentication relies on an asymmetric mathematical key pair:

  • Private Key (id_ed25519): Stored securely on your local computer. You must NEVER share, email, or expose this file to anyone!
  • Public Key (id_ed25519.pub): Uploaded to your GitHub account. When you connect, GitHub uses your public key to encrypt a challenge that only your private key can decrypt.

Step-by-Step Guide: Setting Up SSH Authentication

Step 1: Generate a Modern ed25519 SSH Key Pair

The ed25519 algorithm provides state-of-the-art security, shorter key lengths, and resistance to side-channel attacks compared to legacy RSA.

# Run ssh-keygen using your GitHub email address:
$ ssh-keygen -t ed25519 -C "your_email@example.com"

When prompted:

  1. "Enter file in which to save the key": Press Enter to accept the default location (~/.ssh/id_ed25519).
  2. "Enter passphrase": Type a secure passphrase (or press Enter twice for passwordless convenience).

Step 2: Add Your Key to the Local SSH Agent

# Start the background ssh-agent service:
$ eval "$(ssh-agent -s)"

# Add your private key to the agent:
$ ssh-add ~/.ssh/id_ed25519

Step 3: Copy Your Public Key to Clipboard

# On Windows (Git Bash):
$ clip < ~/.ssh/id_ed25519.pub

# On macOS:
$ pbcopy < ~/.ssh/id_ed25519.pub

# On Linux:
$ cat ~/.ssh/id_ed25519.pub
# Copy the printed line starting with 'ssh-ed25519 AAAAC3Nza...'

Step 4: Add Public Key to GitHub Account

  1. Log in to GitHub and click your profile icon → Settings.
  2. In the left sidebar, click SSH and GPG keys.
  3. Click the green New SSH key button.
  4. Give it a descriptive Title (e.g. "Dell XPS Laptop - Windows 11").
  5. Paste your public key into the Key box.
  6. Click Add SSH key.

Step 5: Test Your SSH Connection

Verify your authentication with GitHub's servers:

$ ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Congratulations! You are now securely authenticated with GitHub via SSH.

Converting Existing HTTPS Repositories to SSH

If you previously cloned your repository using HTTPS, update the remote URL to SSH to start using your key:

git remote set-url origin git@github.com:username/repository.git

Explore Related Git & GitHub Tutorials & Next Steps

Strengthen your version control mastery by studying these connected classes:

GitHub Personal Access Tokens

Alternative HTTPS authentication method using fine-grained security tokens.

Configuring Remote SSH URLs

Switch repository remotes from HTTPS URLs to git@github.com: SSH endpoints.

GitHub Platform Settings

Add your SSH public key to GitHub account profile settings.

SSH Permission Denied Troubleshooting

Fix Permission denied (publickey) errors using ssh-add and config files.

Frequently Asked Questions (FAQ) - Student & Interview Review

ed25519 is based on Edwards-curve Digital Signature Algorithm (EdDSA). It provides higher cryptographic security than standard 2048-bit or 4096-bit RSA keys, generates smaller key sizes, and executes significantly faster.
This error occurs if your SSH agent isn't running, your private key hasn't been added (`ssh-add ~/.ssh/id_ed25519`), or your public key was pasted into GitHub with trailing spaces or missing lines.
Yes! Create a `~/.ssh/config` file with host aliases (e.g. `Host github-work` and `Host github-personal`) pointing to different `IdentityFile` paths.

Next Step in Your Git & GitHub Learning Path:

Advance your software engineering skills with the next topic in our synchronized curriculum.

Continue to PAT & Credentials → Previous: ← Tagging & Releases | Full Syllabus

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!