You can use the Cloud API to add an existing SSH key to your account or generate a new SSH key pair.
Note
Following these instructions won’t add the SSH key to existing instances.
To add SSH keys to existing instances, read our FAQ on using more than one SSH key
Add an existing SSH key to your account
To add an existing SSH key to your account:
-
Generate an API key if you don’t have one already.
-
Create a file named
ssh-key.json
that contains the necessary payload. For example:{ "name": "my-new-key", "public_key": "ssh-ed25519 KEY COMMENT" }
-
Run the following command:
curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/ssh-keys -d @ssh-key.json -H "Content-Type: application/json" | jq .
Replace API-KEY with your actual API key. Don’t remove the trailing colon (:).
Generate a new SSH key pair
To generate a new SSH key pair:
-
Generate an API key if you don’t have one already.
-
Run the following command:
curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/ssh-keys -d '{ "name": "my-generated-key" }' -H "Content-Type: application/json" | jq -r '.data.private_key' > my-generated-private-key.pem
Replace API-KEY with your actual API key. Don’t remove the trailing colon (:).
-
The private key for your SSH key pair will be saved as
my-generated-private-key.pem
.Run
chmod 400 my-generated-private-key.pem
to set the correct file permissions for your private key.