Reputation: 1278
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:
Upvotes: 32
Views: 11116
Reputation: 1323713
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.
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"
}
And See GitLab 15.1 (June 2022) adds:
Deploy keys by user API
Previously, to enable deploy keys for a group of projects, administrator access was required to retrieve the
id
of the deploy key.This release adds a new API endpoint (
GET /users/:id_or_username/project_deploy_keys
) to retrieve all the keys accessible by a given user, so you can complete this task without waiting for an administrator.In a future iteration, the API will also include public deploy keys.
See Documentation and Issue.
Upvotes: 2
Reputation: 1278
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.
Upvotes: 43