What is the public URL for the Github public keys

自古美人都是妖i 提交于 2019-12-18 10:22:58

问题


I heard that there was a public URL for all users on github where you can access their public keys or they can supply that URL of all their public keys. Is this true? If so what is that URL. Does it exist for bitbucket as well?


回答1:


You can get with:

curl https://github.com/<username>.keys

Replace <username> with the actual username of the GitHub user.

This is useful when you set login permission to other servers. Just save its output into ~/.ssh/authorized_keys. To append it to the end from the command line:

curl https://github.com/<username>.keys | tee -a ~/.ssh/authorized_keys

It can also be done using Github API

curl -i https://api.github.com/users/<username>/keys

For bit bucket you can use the following: (This call requires authentication.)

curl -i https://bitbucket.org/api/1.0/users/<accountname>/ssh-keys



回答2:


GPG public keys are now available at https://github.com/<username>.gpg




回答3:


Works for gitlab same way too.

https://gitlab.com/<username>.keys

Works nicely in bash scripts too.

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


来源:https://stackoverflow.com/questions/16158158/what-is-the-public-url-for-the-github-public-keys

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