When creating a droplet via the API, you can pass in an SSH key.
What is the format of the key? I am guessing it would be like this, based on return value of the List All Keys API:
{“ssh_keys”:[{“id”:263654,“fingerprint”:“11:37:44:86:62:15:86:5f:0c:7d:41:0b:39:cb:3c:44”,“public_key”:“ssh-rsa ZZZB3NzaC1yc2EAAAADAQABAAABAQC6vHxLRqVEN2Ze9f8ii634wP5f0Ysua+zqcedJFy8D6/biGE2b0pr0fZoB0lyypu3d6uxt8DvxNNRSgcDiZ6JUoTqPWVY252xgaykghBuNsTSFboAT+c/J9/8GQnTJx5PbiUAMeOBsQ6bU3rkhidhsxDyUzp8PyvTHZxopuCZ/QD/qTRgnpXLiV5/RiKMfg69dRLpG9nTWAfXKb4cwBQesPvfSzPemyMWorkLRbnGlDH3s81yIRNDTO9/LKMIPov715lXF4njbvazSnqjLMLNW4MTvSpUt6LFBv4gKCHgqK0V68QV4Py6BDWhpI0nyzZRlnAxKThbJ3nGDThc4d8m5x tom@tomsmacbook.local”,“name”:“For tomsmacbook”}],“links”:{},“meta”:{“total”:1}}
I am still a little fuzzy about SSH and so am not sure exactly what SSH key to pass in. I am guessing I want it to be the public key file (named id_rsa.pub by default) that was created at the same time as the private key my machine uses?
Thanks much.
P.S. Key contents, machine IDs, etc. were changed to protect the innocent.
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!
This works for me:
curl -X GET "https://api.digitalocean.com/v2/account/keys" -H "Authorization: Bearer $DO_API_TOKEN"
It works for me when use the following;
curl -X POST “https://api.digitalocean.com/v2/droplets” -d’{“name”:“server1.example.com”,“region”:“nyc3”,“size”:“512mb”,“image”:“centos-6-5-x64”,“ssh_keys”:[“95:0d:c5:a9::xxxx:xxxx:f7:fa”]}’ -H “Authorization: Bearer $TOKEN” -H “Content-Type: application/json”
$TOKEN is my API key
hi, instead of the actual key you have to send the ID of the key.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.