Report this

What is the reason for this report?

Is it possible to get the ssh key (name or id) of a droplet through api?

Posted on February 14, 2020

Would like to know if we can get the name or id of the ssh key of a droplet through API because while creating droplet from the snapshot I don’t want pass all the keys in my account. Is there any other way to solve it.



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.

Hello, @vimalSeal

You can check our official documentation of the API via this link: https://developers.digitalocean.com/documentation/v2/

You can check the SSH Keys part of the page.

id - This is a unique identification number for the key. This can be used to reference a specific SSH key when you wish to embed a key into a Droplet.
fingerprint - This attribute contains the fingerprint value that is generated from the public key. This is a unique identifier that will differentiate it from other keys using a format that SSH recognizes.
public_key - This attribute contains the entire public key string that was uploaded. This is what is embedded into the root user's authorized_keys file if you choose to include this SSH key during Droplet creation.

name - This is the human-readable display name for the given SSH key. This is used to easily identify the SSH keys when they are displayed.

Let me know how it goes.

Regards, Alex

Hello, @vimalSeal

Thanks for clearing this out.

I think if you follow up my suggestion this should help you to create the new droplet and to use the ssh_key that was attached/used with the existing droplet in question.

Regards, Alex

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.