Connect with SSH from Cloud Shell

Azure Portal, Hands On10 minutesFree tierSteps checked 25 October 2026By Cloud Hands On

In this task you'll find how to connect to a VM.

SSH is how you sign in to a Linux VM and type commands on it. You need three things: the VM's public IP address, the user name and the private key file you downloaded when you created it.

Cloud Shell has SSH built in, so you can connect from the browser without installing anything.

Example. A SS Kaiser engineer gets an alert that a web server's disk is full. They open Cloud Shell, connect with SSH and clear out old log files in a couple of minutes.

Before you start

You need: Reader on the VM (to see its address), plus the private key. Time: 10 minutes.

Where to look

  1. Virtual machines
  2. vm-practice
  3. Connect

Steps

  1. Open vm-practice and copy its Public IP address from Overview.
  2. Select Connect in the left menu to see the ways to connect. Native SSH is the one used here.
  3. Open Cloud Shell (the >_ icon in the top bar) and choose Bash.
  4. In Cloud Shell, select Manage files, then Upload, and upload the .pem file you downloaded.
  5. Protect the key, then connect, replacing the file name and IP address with yours:Type chmod 400 vm-practice_key.pem, then ssh -i vm-practice_key.pem azureuser@<public IP>
  6. Type yes when asked about the host's fingerprint. You're now on the VM: try hostname and uptime.
  7. Type exit to leave the VM.

Commands

# Find the VM's public IP address
az vm show --resource-group rg-portal-practice --name vm-practice \
  --show-details --query publicIps --output tsv

# Connect (the key was saved in ~/.ssh if you created the VM with the CLI)
ssh azureuser@<public IP>

Watch out for

Cost
Connecting is free. Azure Bastion costs money in most of its tiers, so check the price before choosing it.
Security
Anyone with the private key can sign in, so never email it or put it in a shared folder. Delete the copy in Cloud Shell when you've finished.
Common mistakes
A 'permissions are too open' error means the key file needs chmod 400. A timeout usually means port 22 is blocked by the network security group or the VM is stopped.

Clean up

Delete the .pem file from Cloud Shell when you've finished, with rm vm-practice_key.pem. The VM itself is removed with the resource group at the end of this section.

Words to know

SSH
Secure Shell: an encrypted way to sign in to a Linux machine and run commands.
Public IP address
The address the VM can be reached on from the internet.
Azure Bastion
A service that lets you connect to VMs through the portal without giving them a public IP.

Tick off each step and track your progress in the guide.

Open this task in Azure Portal, Hands On

Keep going