How to use ssh authentication with github API?

谁说胖子不能爱 提交于 2021-01-20 16:20:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!