问题
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
回答1:
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://git@api.github.com
, 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...
来源:https://stackoverflow.com/questions/15044534/how-to-use-ssh-authentication-with-github-api