How to SSH to an Azure Instance

So you have created a Linux server on Azure for yourself, so how do you SSH directly onto your new server? It may sound like such a simple thing to do, but believe me there are a lot of things that can cause you issues when trying to SSH.

To get SSH to work properly. You must have the following in place:

  • An Active Azure Subscription:
    Needless to say, you need an active Azure subscription and the necessary permissions to manage virtual machines.
  • Deployed Azure VM:
    You should have already deployed an Azure virtual machine running within your Azure subscription.
  • SSH Client:
    Install an SSH client on your local machine. Popular choices include PuTTY (Windows), OpenSSH (Linux/macOS), or the Azure Cloud Shell (browser-based).
  • Network Connectivity:
    Verify that your local machine has network connectivity to reach the Azure virtual machine. This is more complicated than it sounds. The easiest option is to have a public IP (however this is not the most secure). If you are on a business network, its likely you will access Azure over a VPN or an Express Link. If this is the case you will need access via the VPN endpoints. Contact your local network administrator if you are experiencing issues.

SSH to Azure Procedure:

Step 1 – Retrieve Your IP address

Access Azure and get your instance IP address.

  • Navigate to the Azure Portal (https://portal.azure.com/).
  • Locate and select your Azure virtual machine.
  • Within the VM’s overview page, find and copy the Public IP Address.

If your Azure VM doesn’t have a public IP address, you’ll need to utilize an alternative method to establish an SSH connection. Here are the common approaches:

  1. Azure Bastion:
  • This is the most secure and recommended approach. Azure Bastion provides a fully managed PaaS service that allows you to connect to your Azure VMs over SSH and RDP directly from the Azure portal, without the need for a public IP address on the VM itself.  

    Azure Bastion – Fully Managed RDP/SSH azure.microsoft.com
  1. Point-to-Site VPN:
  1. ExpressRoute or Site-to-Site VPN:

Step 2 – Use an SSH Client to establish an SSH Connection

For Linux/macOS/Azure Cloud Shell:

  • Launch your preferred SSH
  • Open a terminal window.
  • Execute the following command, replacing <public-ip-address> with the actual public IP address of your VM and <username> with the appropriate username for your VM (often ‘azureuser’):
ssh <username>@<public-ip-address>
  • If prompted, provide the password associated with the specified username on your Azure VM.
    (Recommended) If you have set up SSH key-based authentication, your SSH client should automatically handle authentication using your private key.

For Windows use PuTTY:

 <username>@<public-ip-address>
  • If prompted, provide the password associated with the specified username on your Azure VM.
    (Recommended) If you have set up SSH key-based authentication, your SSH client should automatically handle authentication using your private key.
  • Access Granted:
    Upon successful authentication, you will be presented with a command-line interface within your Azure virtual machine. You can now execute commands and manage your VM remotely.

Important Considerations:

  • Network Security Group (NSG): Ensure that your VM’s Network Security Group allows inbound traffic on port 22 (SSH).
  • SSH Key-Based Authentication: It is strongly recommended to set up SSH key-based authentication for enhanced security.
  • Azure Bastion: For a more secure and managed way to connect to your Azure VMs over SSH, consider using Azure Bastion.
Elsewhere On TurboGeek:  Your Grafana Certificate (HTTPS SSL) Questions Answered

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »