v1
latestOpenAPI 3.0.02026-07-1771620.9 KBAdd SSH key
Add an SSH key
To use an existing key pair, enter the public key for the public_key property of the request body.
To generate a new key pair, omit the public_key property from the request body. Save the private_key from the response somewhere secure. For example, with curl:
curl https://cloud.lambdalabs.com/api/v1/ssh-keys \
--fail \
-u ${LAMBDA_API_KEY}: \
-X POST \
-d '{"name": "new key"}' \
| jq -r '.data.private_key' > key.pem
chmod 400 key.pem
Then, after you launch an instance with new key attached to it:
ssh -i key.pem <instance IP>
post/ssh-keys
Request body
Example request
{
"name": "newly-generated-key"
}Response
OK
Example response
{
"data": {
"id": "0920582c7ff041399e34823a0be62548",
"name": "newly-generated-key",
"public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfKpav4ILY54InZe27G user",
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nKEY CONTENT-----END RSA PRIVATE KEY-----\n"
}
}