Git to GitHub with your SSH Key

a brief note for my exocortex when adding an existing git repo to github and using ssh for Authentication. The default document seems to assume username and password, which is so last year.

Assuming the github repo has been created, the from the project directory :

$git remote set-url origin ssh://git@github.com/yourGitHubUserName/GitHubRepoName.git

(you might be able to just do “add” rather than “set-url”)

and then push as usual :

$git push -u origin master

another piece of the puzzle (and to close the loop, as per GitHub Help : Deploying Using ssh agent forwarding) is the allow your deployment server to connect with github without username/password (in my case deploying with Capistrano) is to ssh to that server with user you with do your deploy with and do :

$ssh git@github.com

I’ve sure that variations of this will work with other external/internal git servers.

Leave a Reply