You have created Azure Linux VM. Using PuTTY you are able login to it using username and password. But you want to avoid entering username & password every time you connect to the VM. You can generate and use secure shell (SSH) keys on a Windows computer to create and connect to a Linux virtual machine (VM) in Azure. SSH uses a public-private key pair
- The public key is placed on your Linux VM, or any other service that you wish to use with public-key cryptography.
- The private key remains on your local system. Protect this private key. Do not share it.
>> Install PuTTY and PuTTYgen from this link if not already installed.
Steps to setup-
>>Make sure that you are able to connect to linux VM using PuTTY client with username and password. –
>>Now open PuTTYgen to create public key. Click Generate button and keep your mouse moving (to provide randomness for the key) while it generates the key-
>>Once the key is generated, copy the content [DO NOT CLOSE the PuTTYgen yet]and login to your Azure Portal account-
>>Go to Virtual Machines –> Reset Password –> “Reset SSH Public key” –> provide username and paste the SSH public Key copied in earlier step and click Update button.
>>Now on the Virtual machine–>click Overview–>Click Connect and copy the value of “Login using VM local account” without ssh as shown in below screen shot.
>>Now go to PuTTYgen again and click on “Save private key” button to save this private key and save it without passphrase (Do not share this key with anyone).
>>Now open PuTTY client, paste the login value copied into hostname field and provide some name in “Saved Sessions” and Save it. Leave the connection Type as SSH and port as 22.
>>On left side click Connection–>SSH–>Auth and Browse to the Private key and select the .ppk file
>>Click on Session and Save it
>>Now Click Open and it should directly login to VM without asking for username or password.