Create
Create a New SSH Key
client.gpuDroplets.account.keys.create(KeyCreateParams { name, public_key } body, RequestOptionsoptions?): KeyCreateResponse { ssh_key }
/v2/account/keys
To add a new SSH public key to your DigitalOcean account, send a POST request to /v2/account/keys
. Set the name
attribute to the name you wish to use and the public_key
attribute to the full public key you are adding.
Parameters
Returns
Create a New SSH Key
import Gradient from '@digitalocean/gradient';
const client = new Gradient();
const key = await client.gpuDroplets.account.keys.create({
name: 'My SSH Public Key',
public_key:
'ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example',
});
console.log(key.ssh_key);
{
"ssh_key": {
"name": "My SSH Public Key",
"public_key": "ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example"
}
}
Returns Examples
{
"ssh_key": {
"name": "My SSH Public Key",
"public_key": "ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example"
}
}