How to SSH into Microsoft Azure Virtual Machine
Microsoft Azure Compute Virtual Machine. Learn how to securely connect to your server from any browser without installing native terminal apps like PuTTY or Termius.
Connection Quick Reference
- Default Username:azureuser
- Authentication:Password or SSH Key
Network Security Groups (NSGs) in Azure
Like AWS, Microsoft Azure defaults to a secure-by-design posture. When you deploy a Linux Virtual Machine, the network interface is associated with a Network Security Group (NSG) which dictates exactly what traffic is allowed in and out of the server.
If you cannot connect to your VM at all (resulting in a Connection timed out error), the most likely culprit is that your NSG is blocking port 22.
To verify your configuration:
- Navigate to the Azure Portal and find your Virtual Machine.
- In the left-hand menu under Settings, click on Networking.
- Look at the Inbound port rules. You should see a rule specifically allowing SSH (Port 22) traffic from your source IP (or
Anyif you left it open). - If it's missing, click Add inbound port rule, set the Destination port ranges to 22, the Protocol to TCP, and the Action to Allow.
Locating Your Public IP Address
To route your SSH connection over the internet, you need the VM's public IP address.
- In the Azure Portal, go to your Virtual Machine's Overview page.
- Look on the right side of the summary panel for Public IP address.
- Copy this address. Note that if you are using a dynamic IP allocation, this IP address will change if the VM is deallocated (stopped). For persistent servers, you should configure a Static IP address.
Authentication on Azure Linux VMs
During the VM creation process, Azure gives you a choice between two authentication types: SSH public key (recommended) or Password. Azure also asks you to define an administrator username (the default is often azureuser, but you could have chosen anything).
Unlike AWS, Azure allows password authentication out of the box if you explicitly select it during deployment. However, SSH keys remain the vastly superior option for security.
If you selected SSH public key, Azure either allowed you to generate a new key pair (downloading the .pem private key to your machine) or use an existing public key.
Connecting with SSHDock
SSHDock abstracts away the complexities of dealing with Windows native SSH clients, WSL, or PuTTY when connecting to Azure VMs.
- Launch SSHDock and click to create a new connection.
- Host: Paste the Public IP address of your Azure VM.
- Port: Leave as 22.
- Username: Enter the administrator username you defined during setup (e.g.,
azureuser). Do not useroot, as Azure prevents direct root logins. - Authentication:
- If you used a password: Select Password authentication and enter it.
- If you used an SSH key: Select Private Key authentication. Open the
.pemfile you downloaded from Azure in a text editor, copy the entire string, and paste it into SSHDock.
- Click Connect.
Accept the host key fingerprint on your first connection to establish the encrypted tunnel.
Troubleshooting Common Azure Issues
Permission Denied (publickey)
If SSHDock rejects your private key, ensure you are logging in with the exact administrator username you defined during creation. If you try to log in as root or ubuntu when your username is azureuser, the connection will fail.
If you lost your private key, you can reset the SSH configuration directly from the Azure Portal. Go to your VM, scroll down the left menu to Help > Reset password, select "Reset SSH public key", and provide a new public key.
Connection Timed Out
Double-check the Network Security Group (NSG) attached to your VM's network interface. If the NSG allows port 22 but you still time out, check if the VM is associated with a virtual network (VNet) that routes traffic through an Azure Firewall or a Network Virtual Appliance (NVA) that might be dropping the packets.