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

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.

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

Hello, @vimalSeal

You can check our official documentation of the API via this link:

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