As I was following thought the tutorial on the same topic,
https://www.digitalocean.com/community/tutorials/how-to-use-terraform-with-digitalocean
I successful was able to create a nginx server but then an error happened, beginning from the md5 of ssh public key <Failed to parse ssh private key: ssh: cannot decode encrypted private keys>
The tutorial is recent and I’m running this on MacOS.
Any help will be appreciated

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.

×
4 answers

I’m not sure about the tutorial. But look at this resource. It allows you to create a ssh key on DO that can then be used to access your droplets. I find it a lot easier than what is in the tutorial. If you need help I can assist you if you show your current terraform files. But the examples in the terraform docs are usually good and self explanatory if you understand how the resources of the provider work.

yes I have the same TF file that is used within the tutorial. However, the ssh keys that is encrypted poorly is not being sync. An error is thrown because of this and that DO cannot decrypt the poor encryption.
Error: Failed to parse ssh private key: ssh: cannot decode encrypted private keys
it’s the same as the one I added to my account

Upon further researching, I cam across this troubleshooting
https://stackoverflow.com/questions/54982050/parseprivatekeywithpassphrase-returns-ssh-cannot-decode-encrypted-private-keys

Below states that DO doesn’t support openSSh encrypted keys

If you look at the docs here : https://www.terraform.io/docs/provisioners/connection.html. I don’t see a field to set the pass for the key. So I would try again with an unencrypted key and it should work. Alternatively, you could simply use the userdata field instead of remote-exec. I’m no cloud init expert, but I believe it wouldn’t require a ssh connection then. Also like I said, I would really add the key to DO so that you don’t need so many variables and can just reference the key from your digitaloceanssh_key resource.

Submit an Answer