by: Helge, published: Dec 6, 2025, in

GitHub: Authenticated Access via SSH

This article describes how to set up authenticated access to a (private or public) GitHub repository from Linux.

Create & Set Up an SSH Key

SSH Key Creation

Create a new SSH key:

# 1. Adjust the email
# 2. Set a strong passphrase when asked
ssh-keygen -t ed25519 -C "[email protected]"

Rename the new key to whatever descriptive name you favor (I’m simply using github):

mv ~/.ssh/id_ed25519 ~/.ssh/github
mv ~/.ssh/id_ed25519.pub ~/.ssh/github.pub

SSH Key Setup: Local

Specify that the new key is to be used for github.com by adding the following to ~/.ssh/config:

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/github
  IdentitiesOnly yes

SSH Key Setup: GitHub

Add the public key to your GitHub account at Settings > SSH and GPG keys > New SSH key.

Enable Automatic Authentication

Start an SSH agent for your terminal session and add the key to be used. Supply the key’s passphrase when asked:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/github

With the above in place, the git command won’t ask you for the passphrase to you private SSH key anymore – in the current terminal session.

Test Authentication

ssh -T [email protected] -v

More verbose output:

ssh -vvT [email protected] -v

Repo: Check Out via SSH (not HTTPS)

If the repository was checked out via HTTPS, switch to SSH:

git remote set-url origin "$(git remote get-url origin | sed -E 's#https://github.com/(.+)#[email protected]:\1#')"

Previous Article Fixing IPv6 Intermittent Packet Loss Caused by Windows Firewall