Create an SSH key
3 min tutorial
What you'll build
An SSH key registered on your account, ready to attach to any Compute Instance you create.
Prerequisites
- A SonicInfra account.
- An SSH key pair on your local machine (
ssh-keygen -t ed25519), or a GitHub account with keys attached.
Open SSH Keys
Click SSH Keys in the sidebar.
Create a new key
Click + Create SSH Key.
Fill out the key details
- Web
- CLI
- Terraform
Fill in the fields, then click Create SSH Key:
- Key Source — leave as Paste public key content, or switch to Import from GitHub to pull keys from a GitHub username instead.
- Public Key — paste the contents of your public key file (e.g.
~/.ssh/id_ed25519.pub). - Name — pick something you'll recognize, like
my-laptop. Importing from GitHub defaults this to your GitHub username.
sonic ssh-keys create my-laptop \
--publicKey "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDemoOnlyDoNotUseThisKeyGkPZ user@example.com"
# Generated by SonicInfra
# Review before applying — some fields may need adjustment
# (e.g. cloud_init requires a YAML string in the Terraform provider)
resource "sonicinfra_ssh_key" "my_laptop" {
name = "my-laptop"
public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDemoOnlyDoNotUseThisKeyGkPZ user@example.com"
}