12

Is there a simple endpoint for retrieving a users gpg public key?

For SSH keys, github.com/<username>.keys, is there something similar for gpg keys?

Related: What is the public URL for the Github public keys

cdignam
  • 1,376
  • 1
  • 15
  • 21

3 Answers3

17

If you do not want to use the API, because you do not want to process the data returned, you can get a raw key from:

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

The output can be used directly for import.

$ curl https://github.com/web-flow.gpg | gpg --import
jnovack
  • 7,629
  • 2
  • 26
  • 40
7

You can try using the GitHub API for GPG Keys:

List GPG keys for a user

GET /users/:username/gpg_keys

Lists the GPG keys for a user. This information is accessible by anyone.

weiji14 proposes in the comments:

You can get the keys via the command line using

curl https://api.github.com/users/<username>/gpg_keys

Since Oct. 2021 and GitHub CLI gh 2.2.0, you also have gh gpg-key list:

gh gpg-key list [flags]
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Also github.com/<username>.gpg works, at least within GHE it does, I haven't verified on public github

mross
  • 11
  • 1