Create a key pair before you launch an instance. Import a key you already have, or have the platform generate one.
Before you begin
- A project to create the key pair in. Key pairs belong to one project.
- The
originCLI, signed in. See CLI access.
Import an existing key
-
If you don’t have a key yet, create one locally:
Terminal window ssh-keygen -t ed25519 -f ~/.ssh/origin-cloud -
Import its public half. Pass the full OpenSSH public key line:
Terminal window origin compute import-key-pair \--project-urn <project-urn> \--name my-key \--public-key "$(cat ~/.ssh/origin-cloud.pub)"A key with an unsupported type, or more than one line, is refused.
-
Verify that the key pair is listed:
Terminal window origin compute list-key-pairs --project-urn <project-urn>
Generate a key pair
-
Generate the key pair:
Terminal window origin compute generate-key-pair \--project-urn <project-urn> \--name my-keyThe response contains
privateKey, anssh-ed25519private key in OpenSSH format. -
Save
privateKeyto a file right away, and restrict its permissions:Terminal window chmod 600 ~/.ssh/origin-cloudImportant: The private key is returned only in this response. The platform doesn’t store it and can’t show it again. If you lose it, delete the key pair and create a new one.
-
Verify that the key pair is listed:
Terminal window origin compute list-key-pairs --project-urn <project-urn>
Using the API
The importKeyPair and generateKeyPair mutations take the same inputs. Request privateKey in the generateKeyPair selection, or you can’t get it later:
mutation { compute { generateKeyPair(input: { projectUrn: "<project-urn>", name: "my-key" }) { urn publicKey privateKey } }}Next steps
- Launch an instance with the key pair