How to ssh to Azure VM using private IP address from internet

SeaDude picture SeaDude · May 27, 2018 · Viewed 7.3k times · Source

I'm new to Azure. Just deployed an Ubuntu VM but thought I'd only create a private IP address, no public IP.

How do I ssh from my laptop at home to the Azure VM using the 10.x.x.x IP address?

I've tried:

  • Using the Azure Cloud Shell but connection just times out
  • Using ssh on my laptop, but its looking for the VM on my LAN and times out.

Answer

Joel Guerra picture Joel Guerra · May 27, 2018

You can't SSH from your local machine to your VM with a private IP because your machine isn't in the same network as the VM. You would only be able to SSH to the VM from another VM on the same virtual network.

In order to SSH to your VM from outside of the vnet you will need a NIC attached with a Public IP and the default port of 22 open on your Network Security Group.

Edit: because I couldn't find a relevant document for this I wrote a blog post. https://medium.com/@joelatwar/how-to-ssh-to-your-azure-linux-vms-with-username-and-password-from-windows-linux-or-mac-df7d07ea3be1