SSH keys
Add and remove the SSH and signing keys of your account.
Last updated
On this page
Description and operation
General
Keys belong to your account, not to a team or a workspace. Every team where you are an active member accepts them. You add only the public half; its SHA-256 fingerprint is the key's _id.
| Kind | Used for | Gives access |
|---|---|---|
| SSH key | Git over SSH. | Yes. |
| Signing key | Verified commits. An SSH key or an OpenPGP signing key. | No. |
One SSH key can be both an SSH key and a signing key; these are two entries. A key without a name takes the key's comment.
Tasks
Add an SSH key
Reason for the task: Clone and push over SSH.
Job set-up
- Access: you.
- References:
POST /v1/keys.
Procedure
Copy your public key line, for example from
~/.ssh/id_ed25519.pub.Add the key. Set
keyto the line from step 1.from kloudlite import Kloudlitekl = Kloudlite()k = kl.request("POST", "/v1/keys", body={"name": "laptop", "key": "ssh-ed25519 AAAA... you@laptop"})print(k["_id"])import { Kloudlite } from "./index.ts";const kl = new Kloudlite();const k = (await kl.request("POST", "/v1/keys", { name: "laptop", key: "ssh-ed25519 AAAA... you@laptop" })) as { _id: string };console.log(k._id);kl := kloudlite.New(kloudlite.Options{})var k map[string]anyerr := kl.Request("POST", "/v1/keys", kloudlite.RequestOptions{ Body: map[string]any{"name": "laptop", "key": "ssh-ed25519 AAAA... you@laptop"}, Out: &k,})if err != nil { log.Fatal(err)}fmt.Println(k["_id"])require_relative "kloudlite"kl = Kloudlite::Client.newputs kl.request("POST", "/v1/keys", body: { name: "laptop", key: "ssh-ed25519 AAAA... you@laptop" })["_id"]var kl = new Kloudlite();System.out.println(kl.request(new Kloudlite.RawRequest().method("POST").path("/v1/keys") .body("{\"name\":\"laptop\",\"key\":\"ssh-ed25519 AAAA... you@laptop\"}")));kloudlite request POST /v1/keys --body '{"name": "laptop", "key": "ssh-ed25519 AAAA... you@laptop"}'
Close-out
- Make sure that the
_idequals the fingerprint fromssh-keygen -lf ~/.ssh/id_ed25519.pub.
Add a signing key
Reason for the task: Show your commits as verified.
Job set-up
- Access: you.
- References:
POST /v1/keys.
Procedure
Set git to sign with SSH. Skip this step for an OpenPGP key.
git config gpg.format sshAdd the key with
signingset to true. For OpenPGP, setkeyto the output ofgpg --armor --export.kl.request("POST", "/v1/keys", body={"name": "laptop signing", "key": "ssh-ed25519 AAAA... you@laptop", "signing": True})await kl.request("POST", "/v1/keys", { name: "laptop signing", key: "ssh-ed25519 AAAA... you@laptop", signing: true });err := kl.Request("POST", "/v1/keys", kloudlite.RequestOptions{ Body: map[string]any{"name": "laptop signing", "key": "ssh-ed25519 AAAA... you@laptop", "signing": true},})if err != nil { log.Fatal(err)}kl.request("POST", "/v1/keys", body: { name: "laptop signing", key: "ssh-ed25519 AAAA... you@laptop", signing: true })kl.request(new Kloudlite.RawRequest().method("POST").path("/v1/keys") .body("{\"name\":\"laptop signing\",\"key\":\"ssh-ed25519 AAAA... you@laptop\",\"signing\":true}"));kloudlite request POST /v1/keys --body '{"name": "laptop signing", "key": "ssh-ed25519 AAAA... you@laptop", "signing": true}'
Close-out
- Show your signing keys with
kind=signingas in task 003. Make sure that the new_idstarts withsign:.
Show your keys
Reason for the task: List the keys of your account.
Job set-up
- Access: you.
- References:
GET /v1/keys.
Procedure
Show the keys. Add the query
kind=signingto show signing keys instead.for k in kl.request("GET", "/v1/keys"): print(k["_id"], k["name"])const keys = (await kl.request("GET", "/v1/keys")) as { _id: string; name: string }[];for (const k of keys) console.log(k._id, k.name);var keys []map[string]anyif err := kl.Request("GET", "/v1/keys", kloudlite.RequestOptions{Out: &keys}); err != nil { log.Fatal(err)}for _, k := range keys { fmt.Println(k["_id"], k["name"])}kl.request("GET", "/v1/keys").each { |k| puts "#{k["_id"]} #{k["name"]}" }System.out.println(kl.request("GET", "/v1/keys"));kloudlite request GET /v1/keys
Close-out
- Make sure that each key in the list is still in use.
Remove a key
Reason for the task: Revoke a key that you no longer use.
Job set-up
- Access: you.
- References:
DELETE /v1/keys/{*id}.
A removed key stops working for git over SSH at once.
Procedure
Find the
_idof the key as in task 003.Remove the key. Replace
SHA256:IDwith its_id.kl.request("DELETE", "/v1/keys/SHA256:ID")await kl.request("DELETE", "/v1/keys/SHA256:ID");if err := kl.Request("DELETE", "/v1/keys/SHA256:ID", kloudlite.RequestOptions{}); err != nil { log.Fatal(err)}kl.request("DELETE", "/v1/keys/SHA256:ID")kl.request("DELETE", "/v1/keys/SHA256:ID");kloudlite request DELETE /v1/keys/SHA256:ID
Close-out
- Show the keys. Make sure that the
_idis gone.
Troubleshooting
| Symptom | Possible cause | Corrective action |
|---|---|---|
400 with keys belong to you, not to a namespace | The body contains owner. | Remove owner from the body. |
400 with a GPG key can only be added as a signing key | An OpenPGP key was sent without signing. | Add it as a signing key. See task 002. |
409 with that key is already added | The key is already on the account as this kind. | No action needed. |
404 with no such credential | The _id is not one of your keys. | Copy the _id again. See task 003. |
502 with could not read the key | A transient platform error. | Send the request again. |