How to create Azure Virtual Machine and perform login using SSH
Jump to navigation
Jump to search
Generating SSH keys (from Windows machine)
- Download puttygen.exe from:
- Run the puttygen.exe
- Click Generate and follow the on-screen instructions to generate a new key.
- Note: Make sure you create keys with at least 2048 bits
- Click Save private key to write your private key to a file with a .ppk extension.
- Click Save public key to write your public key to a file for later use.
Generating SSH keys (from Linux machine)
- Login to the Linux machine console
- Run the following command to generate the SSH key pair:
- ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME]
- Note: Replace KEY_FILENAME with the actual private key file name
- Change the permissions of the SSH private key using the command below:
- chmod 400 ~/.ssh/[KEY_FILENAME]
- Note: Replace KEY_FILENAME with the actual private key file name
Create Azure VM from the management console
- Login to the Azure Portal:
- From the left pane, click on “Virtual machines” -> from the main pane, click on “Create Virtual machines” -> select a Linux flavor -> select a deployment model -> choose “Resource Manager” -> click on Create
- Fill-in the following details:
- Name: Specify here machine hostname
- VM disk type: Select the disk type according to your needs. For more information and pricing details, see:
- User name: Specify here the username of the administrator of the VM
- Authentication type: Select “SSH public key”
- SSH public key: Open the previously created public key (usually it has no file extension) using a text editor and copy its entire content into memory and paste the content of the public key into the free text field
- Subscription: Select an existing Azure subscription
- Resource group: Select either existing or create a new resource group. For more information, see:
- Location: Select a region close to your location
- Click OK
- Choose a size -> select VM type according to your needs. For more information and pricing, see:
- Click Select
- Fill-in the following details:
- Availability set: Select this option in case your virtual machine requires high availability. For more information, see:
- Disk type and managed disks: Select the settings according to your needs. For more information and pricing details, see:
- Virtual network: Select a VNet according to your needs. For more information, see:
- Subnet: Select the relevant subnet. For more information, see:
- Public IP address: Leave the default settings
- Network security group: Select either to create a new network security group or to select an existing network security group. For more information, see:
- Extensions: Leave the default settings
- Enable auto-shutdown: Select either off (the virtual machine will remain up and running) or on (and configure automatic shutdown on daily basis). For more information, see:
- Monitoring: Leave the default settings
- Click OK
- Click Create
Login to Azure Virtual machine (from Windows machine)
- Login to the Azure Portal:
- From the left pane, click on “Virtual machines” -> locate the relevant virtual machine -> click on the machine name -> from the overview page, write down the "Public IP address" (or "DNS name", if configured)
- Download Putty from:
- Run putty.exe
- From the left pane, under “Connection” -> expand SSH -> click on “Auth” -> from the main pane, under “Authentication parameters”, click on “Browse” -> locate the SSH private key generated by puttygen.exe
- From the left pane, click on “Session” -> from the main pane, under “Host Name (or IP address)” specify the following:
- Username@IP_Address
- Note 1: Replace Username with the account name created during the VM creation phase
- Note 2: Replace IP_Address with the Virtual machine “Public IP address” or "DNS name"
- Under “Saved Sessions”, specify a name for this newly created connection.
- Click on Save
- Click on Open
Login to Azure Virtual machine (from Linux machine)
- Login to the Azure Portal:
- From the left pane, click on “Virtual machines” -> locate the relevant virtual machine -> click on the machine name -> from the overview page, write down the "Public IP address" (or "DNS name", if configured)
- Login to the Linux machine console
- Copy the private key file into ~/.ssh of the currently running user
- Run the following command:
- ssh Username@IP_Address -i ~/.ssh/[KEY_FILENAME]
- Note 1: Replace Username with the account name created during the VM creation phase
- Note 2: Replace IP_Address with the Virtual machine “Public IP address” or "DNS name"
- Note 3: Replace KEY_FILENAME with the actual private key file name