DevFixes
GitHubBeginnerAuthentication

GitHub SSH keys: from zero to a working git push

Create an SSH key, load it into the agent, register it with GitHub, and verify which identity Git uses for a repository.

15 min Published 2026-07-28

Before you start

  • Git is installed.
  • You have access to a GitHub account and repository.

Check the repository remote

Start by confirming that the repository uses the GitHub host and the intended owner.

bash
git remote -v

An SSH remote normally looks like git@github.com:OWNER/REPOSITORY.git.

Create a key

bash
ssh-keygen -t ed25519 -C "your-email@example.com"

Accept the default filename unless you already use that key path for another account.

Load the key

On macOS or Linux:

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

On Windows PowerShell, start the OpenSSH authentication agent and add the key from your profile's .ssh directory.

powershell
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519

Register the public key

Copy the contents of id_ed25519.pub, then add it to the SSH keys page of the GitHub account that should access the repository. Never upload or share the private file without the .pub suffix.

Test before pushing

bash
ssh -T git@github.com

Successful authentication identifies the GitHub username. It does not automatically grant write permission to every repository, so also confirm organization membership, repository access, and branch protection.

Correct the remote when necessary

bash
git remote set-url origin git@github.com:OWNER/REPOSITORY.git
git remote -v

For multiple GitHub accounts, define SSH host aliases and assign a different identity file to each alias.

Errors this tutorial helps prevent

Frequently asked questions

Yes. Repository access is granted to the GitHub account that owns the key, not separately to the key for each repository.

References