SSH Key-Based Passwordless Access for Private GitHub Repositories

My SSH key-based authorization kept failing on a private GitHub repo on a remote machine, even though my SSH keys for that machine were properly registered on the GitHub account. The solution was to force the “git” protocol instead of “http”.

That is, instead of:

url = https://github.com/accountname/reponame.git

use:

url = git@github.com:accountname/reponame.git

in your “.git/config:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
    url = git@github.com:accountname/reponame.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
Share