How to Connect to Azure VM: Simple Steps for Beginners
To connect to an Azure VM, use
Remote Desktop Protocol (RDP) for Windows VMs or SSH for Linux VMs. You need the VM's public IP address, username, and authentication method like a password or SSH key.Syntax
Connecting to an Azure VM depends on its operating system:
- Windows VM: Use
mstsc /v:<public-ip>in Command Prompt or Remote Desktop app. - Linux VM: Use
ssh <username>@<public-ip>in a terminal.
Replace <public-ip> with your VM's public IP address and <username> with your VM's user name.
bash
mstsc /v:<public-ip> # For Windows VM ssh <username>@<public-ip> # For Linux VM
Example
This example shows how to connect to a Linux Azure VM using SSH with a username azureuser and public IP 52.170.12.34.
bash
ssh azureuser@52.170.12.34Output
The authenticity of host '52.170.12.34 (52.170.12.34)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '52.170.12.34' (ECDSA) to the list of known hosts.
azureuser@52.170.12.34's password:
Common Pitfalls
- Missing Public IP: Ensure your VM has a public IP address assigned.
- Network Security Group (NSG) Rules: Check that inbound rules allow RDP (port 3389) for Windows or SSH (port 22) for Linux.
- Wrong Credentials: Use the correct username and password or SSH key.
- Firewall Blocking: Local or corporate firewalls might block the connection ports.
bash
Wrong way: ssh azureuser@52.170.12.34 -p 3389 # Using RDP port for SSH will fail Right way: ssh azureuser@52.170.12.34 # Default SSH port 22
Quick Reference
| Step | Action | Details |
|---|---|---|
| 1 | Find VM Public IP | Go to Azure Portal > Virtual Machines > Your VM > Overview > Public IP address |
| 2 | Check NSG Rules | Ensure inbound port 3389 (Windows) or 22 (Linux) is allowed |
| 3 | Connect to VM | Use mstsc /v:<IP> for Windows or ssh user@<IP> for Linux |
| 4 | Authenticate | Enter your VM username and password or SSH key |
| 5 | Troubleshoot | Verify firewall and network settings if connection fails |
Key Takeaways
Use RDP for Windows VMs and SSH for Linux VMs to connect.
Always verify your VM's public IP and network security rules before connecting.
Use correct username and authentication method (password or SSH key).
Check local and cloud firewalls if connection issues occur.
Azure Portal provides all necessary connection details in the VM overview.