Hey!

I want to get list of all the droplets and SSH key ID linked to those droplets. I’m making this call right now

https://developers.digitalocean.com/documentation/v2/#list-all-droplets

I’m getting the droplet data but is there any way I can get the ID of the SSH key linked to the particular droplet?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hey @gaurav587379,

I don’t think that this is currently possible with the API.

The best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.

https://ideas.digitalocean.com/

Hope that helps!
- Bobby.

Hello, @gaurav587379

To list all of the keys in your account, send a GET request to /v2/account/keys.

The response will be a JSON object with a key set to ssh_keys. The value of this will be an array of key objects, each of which contain the standard key attributes:

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582" "https://api.digitalocean.com/v2/account/keys" 

RESPONSE HEADERS:

content-type: application/json; charset=utf-8
status: 200 OK
ratelimit-limit: 1200
ratelimit-remaining: 767
ratelimit-reset: 1415984218

RESPONSE BODY:

{
  "ssh_keys": [
    {
      "id": 512189,
      "fingerprint": "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
      "public_key": "ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
      "name": "My SSH Public Key"
    }
  ],
  "links": {
  },
  "meta": {
    "total": 1
  }
}

Regards,
Alex