Microsoft Azure Documentation

Connect to a Linux virtual machine on Azure using SSH

This tutorial shows you how to connect to a Linux virtual machine (VM) hosted in Azure using Secure Shell (SSH). SSH is a secure cryptographic network protocol for operating network services securely over an unsecured network.

Prerequisites

Security Note

Always ensure your SSH client and server configurations are up-to-date and follow security best practices to protect your VM from unauthorized access.

Steps to Connect

Step 1: Find your VM's Public IP Address

You need the public IP address of your Azure Linux VM to establish an SSH connection. You can find this information in the Azure portal:

  1. Sign in to the Azure portal.
  2. Navigate to your virtual machine resource.
  3. On the Overview blade, locate the Public IP address. Copy this address.

Step 2: Open your SSH Client

Launch your SSH client application on your local machine.

Step 3: Connect to your VM

Use the following SSH command syntax, replacing {username} with your VM's login username and {publicIpAddress} with the public IP address you found in Step 1:

ssh {username}@{publicIpAddress}

For example, if your username is azureuser and your VM's public IP address is 203.0.113.5, the command would be:

ssh azureuser@203.0.113.5

If this is your first time connecting to this VM, you might see a message like:

The authenticity of host '203.0.113.5 (203.0.113.5)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Type yes and press Enter to continue. This adds the VM's host key to your known hosts list.

Step 4: Enter your Password

You will be prompted to enter the password for your VM's login username. Type your password and press Enter. Note that for security reasons, the password characters will not be displayed as you type.

If you used SSH keys for authentication during VM creation, you will not be prompted for a password. Instead, your SSH client will use your private key to authenticate.

Step 5: Access your VM

Once authenticated, you will see the command prompt for your Azure Linux VM. You can now execute commands on your VM.

azureuser@myvm:~$

Step 6: Disconnect from your VM

When you are finished working on your VM, you can disconnect by typing:

exit

or by pressing Ctrl+D.

Troubleshooting Common Issues

For more advanced connection scenarios, such as using Bastion or connecting via private IP addresses, please refer to the Azure documentation on VM networking.