Disclaimer: Before anyone freaks out, the SSH key shown in this example no longer exists and neither does the VM it was used with.
I was creating a new Ubuntu VM in Azure today as part of a lab exercise today. When I copied the SSH key I had generated from Azure Cloud Shell into the Azure Portal, it kept saying that “SSH Key must be encoded in base64”. A few Google searches didn’t return much and modifying the command I was using wasn’t helping. I finally figured out what I was doing wrong after about 20 minutes: I was copying too much of the data displayed by the cat command. Let’s take a look.
In Azure Cloud Shell I created my SSH Key (take a close look at #2, we are going to come to that in a second):
Next, I ran the command to display the SSH key in the shell. I copied and pasted everything except for “ssh-rsa” at the beginning. Can you spot the problem already?
If you can’t spot the problem, I have highlighted it for you below. The end of the output is part of the key fingerprint that I highlighted in #2 above. Once I removed everything after the “wkAf” sequence at the end, the Azure portal was able to verify that the key was valid.