10

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.

3 Answers 3

8

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for the answer. And is this true even when using Azure Cloud Shell?
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.
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?
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.

Comments

2

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

1 Comment

Provided link directs you to the German page. For non-German speakers like me, here's the English version: azure.microsoft.com/en-us/products/azure-bastion

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.