如何在github API中使用ssh身份验证? [英] How to use ssh authentication with github API?

查看:64
本文介绍了如何在github API中使用ssh身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过命令行(例如,通过curl等)访问GitHub API时,是否可以使用基于ssh的身份验证?

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

FWIW,我尝试了以下操作的多种变体(更改了我指定公共ssh密钥文件的方式),但在每种情况下,仍然会提示我输入密码:

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

推荐答案

如果使用的是ssh,则永远都不会以" yrstruly "身份登录.您将始终以"git"身份进行连接.
您的公共密钥足以使GitHub识别您为" yrstruly ".
而且由于您使用的是https地址,而不是ssh地址,因此该-pubkey 选项可能会被忽略.

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.

有效的ssh地址为: ssh://git@api.github.com ,我不认为Github对其api提出了这种访问方式.

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.

curl --user 选项仅对于https地址是必需的,例如"无法从Private Repo下载Git存档tarball ":

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

这篇关于如何在github API中使用ssh身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆