Report this

What is the reason for this report?

How should I send ssh_keys when creating a droplet API?

Posted on July 2, 2015

I was trying to create a droplet trought API, I created some droplets succesfully without ssh_keys fields, but when I try to use this field I got this error: “are invalid key identifiers for Droplet creation”. I created the key using digital ocean tutorial, after that I got the fingerprint using this command :

ssh-keygen -lf id_rsa.pub

Then I added this fingerprint value as the first argument of a array of ssh_keys field. I was using nodejs in those tests.

I also try to use curl to test this web service, without ssh_keys everything works, but when I add that field I get the same error.

This is my curl command (token and fingerprint modified for this example).

curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer 701d61eabc12d90cf0efd7a57157f2b998a59455873e5db6d2c062d6234d6b37' -d '{"name":"example.com","region":"nyc3","size":"512mb","image":"ubuntu-14-04-x64","ssh_keys": [ "b4:2a:c9:ec:41:ua:a0:yt:95:5e:6b:2e:aa:a0:ef:aa" ] }' "https://api.digitalocean.com/v2/droplets"


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

hi @ryanpq. do you have any actual examples for uploading ssh keys besides pointing to the API docs? I’ve poured through the docs and have experienced issues with this as well. Maybe there is a bug on digital ocean’s end, where they think that the uploaded ssh_keys arent an array, when really they are? Here’s my similar issue. I’ve been banging my head on this for a while, because it appears as if it is very obviously an array… https://www.digitalocean.com/community/questions/the-provided-ssh_keys-value-must-be-an-array

The ssh_keys field when creating a droplet expects an array of ssh key IDs. You first need to add your key to DigitalOcean via this endpoint: https://developers.digitalocean.com/documentation/v2/#create-a-new-key

Then you can use that ID to identify the key.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.