How to use ssh authentication with github API?

kjo picture kjo · Feb 23, 2013 · Viewed 12.1k times · Source

Is there some way to use ssh-based authentication when accessing the GitHub API through the command line (via, e.g., curl, etc.?).

FWIW, I tried many variations of the following (varying the way I specified my public ssh key file) but in every case I was still prompted for my password:

% curl --pubkey ~/.ssh/id_rsa.pub --user yrstruly https://api.github.com/user/repos

Answer

VonC picture VonC · Feb 24, 2013

If you are using ssh, then you would never logon as 'yrstruly'. You would always connect as 'git'.
Your public key would be enough for GitHub to recognize you as 'yrstruly'.
And since you are using an https address, and not an ssh one, that --pubkey option is likely to be ignored.

A valid ssh address would be: ssh://[email protected], and I don't think Github proposes that kind of access for its api.

The curl --user option would be necessary for https address only, as in "Having trouble downloading Git archive tarballs from Private Repo":

curl -sL --user "${username}:${password}" https://github.com...