Github公钥的公共URL是什么

fra*_*ras 31 git github bitbucket public-key

我听说github上的所有用户都有一个公共URL,您可以访问他们的公钥,或者他们可以提供所有公钥的URL.这是真的?如果是这样,该URL是什么.它也适用于bitbucket吗?

fra*_*ras 66

你可以得到:

curl https://github.com/<username>.keys
Run Code Online (Sandbox Code Playgroud)

替换<username>为GitHub用户的实际用户名.

当您将登录权限设置为其他服务器时,这非常有用.只需将其输出保存到~/.ssh/authorized_keys.要从命令行将其追加到末尾:

curl https://github.com/<username>.keys | tee -a ~/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)

它也可以使用Github API完成

curl -i https://api.github.com/users/<username>/keys
Run Code Online (Sandbox Code Playgroud)

对于位桶,您可以使用以下内容:(此调用需要身份验证.)

curl -i https://bitbucket.org/api/1.0/users/<accountname>/ssh-keys
Run Code Online (Sandbox Code Playgroud)

  • @holmb,根据最新文档,此端点需要身份验证.我认为这随着时间的推移而发生变化,我不记得当我第一次发布这个答案时就是这样.https://confluence.atlassian.com/bitbucket/ssh-keys-resource-296911735.html#ssh-keysResource-GET/users/{accountname}/ssh-keys (2认同)

Mik*_*e R 10

gitlab 也以同样的方式工作。

https://gitlab.com/<username>.keys
Run Code Online (Sandbox Code Playgroud)

在 bash 脚本中也能很好地工作。

#GitProvider to fetch public keys (gitlab.com,github.com)
GitProvider="gitlab.com"
GitUsername="username"
curl https://${GitProvider}/${GitUsername}.keys | tee -a ~/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)


Bri*_*n D 9

现在可以在以下位置使用GPG公钥: https://github.com/<username>.gpg


Ita*_*dev 9

此外,这些还提供了一种检索用户 PGP 密钥的方法:

GitHub

https://github.com/USER.keys
https://gitlab.com/USER.gpg
Run Code Online (Sandbox Code Playgroud)

亚搏体育app实验室

https://gitlab.com/USER.keys
https://gitlab.com/USER.gpg
Run Code Online (Sandbox Code Playgroud)