I had the same error when trying to create new VMs using Azure templates
in my case I had to add a few more \n
not only one at the end of the key.
If you have a Public SSH key in a format like this:
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20200611"
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF==
---- END SSH2 PUBLIC KEY ----
Once you copy and paste this into the template field: Admin Public Key * :
I finally got it working if you replace at least four new lines with \n
and remove any extra spaces inside the random generated key.
---- BEGIN SSH2 PUBLIC KEY ----\nComment: \"rsa-key-20200611\"\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF==\n---- END SSH2 PUBLIC KEY ----\n
Another other option is, if you want to keep it exactly following same format, then you can replace any space character ' '
inside the key for '\n'
as well.
Once you do this the format of the key will be correct and you will get the VMs properly created using templates. That is a common copy paste problem replacing new line characters for just a regular space character.