Question

Create DigitalOcean SSH key

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: RuntimeError: HTTPSConnectionPool(host=‘api.digitalocean.com’, port=443): Max retries exceeded with url: /v2/account/keys (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7fc01e880da0>: Failed to establish a new connection: [Errno -2] Name or service not known’,)) fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “HTTPSConnectionPool(host=‘api.digitalocean.com’, port=443): Max retries exceeded with url: /v2/account/keys (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7fc01e880da0>: Failed to establish a new connection: [Errno -2] Name or service not known’,))”}


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,

Can you share the exact API request that you are making?

Usually, to add a new SSH key via the API the request should look as follows:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"name":"My SSH Public Key","public_key":"ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example"}' \
  "https://api.digitalocean.com/v2/account/keys" 

For more information you can check out the documentation here:

https://docs.digitalocean.com/reference/api/api-reference/#operation/create_ssh_key

Best,

Bobby