How should I send ssh_keys when creating a droplet API?

Posted July 2, 2015 4.8k views

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

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":"","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" ] }' ""

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

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:

Then you can use that ID to identify the key.

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…