How does one retrieve an arbritrary user's ssh public keys from GitLab?
GitHub provides this feature. For example: https://github.com/winny-.keys
The GitLab API exposes public keys, however it looks like it requires:
By default, all GitLab SSH keys must go in an . ssh folder under the user's home directory.
Add your public key to GitHubLogin to github.com and bring up your account settings by clicking the tools icon. Select SSH Keys from the side menu, then click the Add SSH key button. Name your key something whatever you like, and paste the contents of your clipboard into the Key text box. Finally, hit Add key to save.
GitHub style ssh public key access was added in GitLab 6.6.0 using the following scheme: http://__HOST__/__USERNAME__.keys
(thanks @bastelflp).
Currently we are running 6.2.3, and we will upgrade.
You also have, with GitLab 14.9 (March 2022):
New API endpoints for keys and tokens
GitLab 14.9 delivers new REST API endpoints:
- Return a single SSH key for a specified user. This is useful to enable GitLab SSH keys to be a Terraform-managed resource.
- Return a single project’s deploy token by ID. This allows for a simple request to return a deploy token instead of returning and sorting through pages deploy tokens with the API.
- Return a single group access token or project access token.
Thank you Timo Furrer for your contribution!
See Documentation, Issue 354889, Issue 355778 and Issue 355893.
Example:
GET /users/:id/keys/:key_id
{
"id": 1,
"title": "Public key",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
"created_at": "2014-08-01T14:47:39.080Z"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With