Ssh – Azure VM, can’t connect to the VM by SSH

azuressh

I have encountered problem during using Azure Virtual Machine.

I have virtual machine, which is running:

Virtual Machine

I it has its own static ip address:
Static address

I have also allowed access from outside:
Access

I know that allowing all ports to outside is bad, but this is just for development.

Now when I try to connect by using SSH to my static IP address in PORT 22 it throws an error message. It is like this address does not even exist.

Why this is happening?

I was able to connect with current settings several months ago, now there is something changed in Azure.

I have also checked the Resource health, it shows to me this:

Health

Also I have opened boot diagnostics, but there are a lot of information.

this is link to my boot diagnostics log file

Best Answer

In Azure, we can't use ping to test Azure VM status, by default Azure will block the public ICMP traffic. To test it, we can use telnet to test it, like this:

C:\Users>telnet xxx.xx.xx.xx 22

By the way, if we shutdown Azure VM by VM command, the Azure portal still show VM is running, only shutdown Azure VM by Azure portal, portal will change Azure vm status to stopped. So we should use telnet to test it.

If we can't telnet this VM, maybe we can restart this VM via Azure portal, then test it again. ( redeploy this VM via Azure portal is a good idea, Azure will use your old config to deploy a new VM, same as your original VM, and new VM will deploy to another host)

We can restart this VM here: enter image description here

More information about redeploy Azure VM, please refer to this link.

If you face difficulties troubleshooting SSH or application access to a Linux virtual machine (VM) in Azure, redeploying the VM may help. When you redeploy a VM, it moves the VM to a new node within the Azure infrastructure and then powers it back on. All your configuration options and associated resources are retained. This article shows you how to redeploy a VM using Azure CLI or the Azure portal.

If restart or redeploy this VM still can't telnet this VM, maybe we should deploy another VM in the same VNet, then we can ping internal IP address to test it running or not.

If we can ping this VM internal IP address, we should reset VM's SSH configure via Azure portal. More information about reset SSh configuration, please refer to this article.

In short, we can restart(or redeploy) this VM and test it. if it does not work, we can reset VM ssh configure. After that, if vm still can't ssh to it, please post your boot diagnostics here.

Related Topic