Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ssh authentication with github API?

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 

like image 628
kjo Avatar asked Feb 23 '13 19:02

kjo


People also ask

How does GitHub SSH authentication work?

Git uses SSH to establish a secure connection through which it can execute commands. You're passing it in your ssh username, git , and the host to connect to, github.com . So far this is normal SSH. You also pass it the path to look for your Git repository, MY_GIT_USERNAME/PROJECT.


1 Answers

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... 
like image 104
VonC Avatar answered Sep 22 '22 13:09

VonC