August 14, 2013

Generating SSH cert for Linux VM running on Azure

This post describes how to generate SSH private and public keys for Linux VM on azure. This post uses “Windows Azure Command Line tool for node.js” to spin up the VM

1.      Install OpenSSL from (go for "Complete package, except sources")

2.      Open the location "C:\Program Files (x86)\GnuWin32\share" create a backup of the file "openssl.cnf"

3.      Open notepad.exe, copy the sample config file content from Save this file with name "openssl.cnf" under "C:\Program Files (x86)\GnuWin32\share"

4.      Run the command prompt as administrator, switch to "C:\Program Files (x86)\GnuWin32\bin". Run the below command

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem -config "c:\Program Files (x86)\GnuWin32\share\openssl.cnf"

5.      Create your VM using CLI tool with --ssh-cert value "myCert.pem"

azure vm create myvmssh3 b4590d9e3ed742e4a1d46e5424aa335e__SUSE-Linux-Enterprise-Server-11-SP3-v103  anuchandy <password> --location "West US" --ssh --ssh-cert "C:\Program Files (x86)\GnuWin32\bin\myCert.pem"

6.      Download puttygen.exe from

7.      Run puttygen.exe, select "File => Load Private Key", You will need to change the file filter to show All Files (*.*) and select "myPrivateKey.key" file generated in step 4

8.      Click on "Save Private Key" and save with name "myPrivateKey.ppk"

10.   Run putty.exe and connect to the VM created by providing host name as "" and select "SSH => Auth" give path to file "myPrivateKey.ppk" generated in step 7 as value for "Private Key file for authentication"

1 comment: