15

Googling was fruitless, as most people have a slightly different variation of this problem.

I am trying to setup an Azure Linux VM with SSH (no password), for access from a Windows machine. 2018 UPDATE: The original requirement was to use WinSCP but I'm ok with using Putty instead (on the Windows machine, which is the SSH Client) .

How can you set up an Azure Linux VM and generate the required keys using as few additional tools as possible, on Windows?

  • 1
    SSH keys are just keys, not certificates. Use a tool like xca to make certificates. – LawrenceC May 7 '15 at 19:37
16

First you need get public key in a format for OpenSSH authorized_keys file.


Once you get the public key in the authorized_keys format, paste it to the "SSH public key" box, when provisioning Azure Linux machine (or when resetting the public key):

enter image description here

  • 1
    That doesn't work. Azure goes through the initial stages of VM setup but then aborts complaining that the key is not X.509 compliant. – Alex R Jul 30 '14 at 18:49
  • 1
    Ok, I followed the instructions at azure.microsoft.com/en-us/documentation/articles/… and they worked. Basically you run "openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem". The .pem needs to be uploaded via the Azure portal. (I'm not posting this as an answer because I did it on my Mac, and the poster asked for a Windows solution. Googling indicates that OpenSSL distributions for Windows exist, but I haven't tried any.) – Rohit Chatterjee Jan 29 '15 at 4:49
  • 1
    Also, the private key generated in my comment above - myPrivateKey.key - needs to be imported into PuttyGen and converted to a PPK. Putty will not use the .key file. – Rohit Chatterjee Jan 29 '15 at 4:51
  • @RohitChatterjee That was all misunderstanding. OP asked about private key (giving an impression he want to use it as host key), while the question was actually about public key. I've updated my answer accordingly. – Martin Prikryl May 8 '18 at 19:38
  • Actually this is still a little off as I wanted to use WinSCP, not Putty. I'm going to edit the question one more time to make this answer correct. – Alex R May 8 '18 at 20:29
2

The correct answer was provided in comments by @Rohit Chatterjee:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem

Explanation:

The Azure portal asks for a PEM / CER as part of the VM provisioning process (though one can provide a password instead). PuttyGen creates a PEM from a PPK as this answer decribes, but the output is not accepted by the portal. If I figure this out I will post an answer here... – Rohit Chatterjee Jan 29 at 4:18 1 up voted

Ok, I followed the instructions at azure.microsoft.com/en-us/documentation/articles/… and they worked. Basically you run "openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem". The .pem needs to be uploaded via the Azure portal. (I'm not posting this as an answer because I did it on my Mac, and the poster asked for a Windows solution. Googling indicates that OpenSSL distributions for Windows exist, but I haven't tried any.) – Rohit Chatterjee Jan 29 at 4:49

Also, the private key generated in my comment above - myPrivateKey.key - needs to be imported into PuttyGen and converted to a PPK. Putty will not use the .key file. – Rohit Chatterjee Jan 29 at 4:51

0

I see this is an older question, but if you're using Windows 10, it's now possible to SSH from the Windows Subsystem for Linux. For that, just set up keys like you would do in regular Linux.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.