7

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.
Charles Xu
  • 29,862
  • 2
  • 22
  • 39
SeaDude
  • 3,725
  • 6
  • 31
  • 68

3 Answers3

7

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

Joel Guerra
  • 4,760
  • 4
  • 12
  • 26
  • Thank you for the answer. And is this true even when using Azure Cloud Shell? – SeaDude May 27 '18 at 04:13
  • 1
    Yes. Because the Cloud shell, while in Azure, isn't in your vnet. Just like when you type 10.x.x.x from your laptop it only searches your local network. – Joel Guerra May 27 '18 at 04:16
  • What if I don't want to have port 22 open to the internet? Would it be possible to do it with azure load balancer and port forwarding? – oderibas Aug 10 '18 at 09:02
4

I have found some other way working.

Temporarily attach the VM with private ip address under a public azure lb, configure a nat rule for ssh in the load balancer.make sure you have allowed the ssh from inside vnet in the nsg where the vm is attached.

SSH into the public load balancer ip and you will be able to access the internal machine via azure load balancer ip.

Haneef Mohammed
  • 1,094
  • 11
  • 11
3

In the meanwhile there exists Azure Bastion which could help you.

Micha
  • 191
  • 1
  • 11