1

I created a resource group and a virtual machine on Azure. After that, I opened the 22 port on my VM to allow the ssh connection. The connection test on the browser succeeds but when I try to connect with PuTTY or with PowerShell through the ssh command, the connection times out. I used these commands

az login

az group create -n testRG -l westeurope

az vm create -g testRG -n testVM --image MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest

az vm --open-port --port 22 -g testRG -n testVM

How can I fix it?

1 Answer 1

0

When executing this command az vm open-port, it creates a Network Security Group (NSG) and applies this rule, it is used as a quick test, I suggest you consider creating a NSG before and then associate to your NIC or SUBNET like described into this article (https://docs.microsoft.com/en-us/azure/virtual-machines/linux/nsg-quickstart).

In order to verify what is going on for this VM, you can use Network Watcher (https://docs.microsoft.com/en-us/azure/network-watcher/network-watcher-monitoring-overview), from this menu you can easily make sure that rules is correct, next hop and other options. In case that everything is ok, you better check Windows firewall or if your service on port 22 is really running inside VM.

To verify if you have port 22 listening inside your Windows VM, run this CMD command

netstat -ano | findstr :22

The output of this command must have at least two line for IPv4 and IPv6 like so:

netstat -ano | findstr :22
  TCP    0.0.0.0:22            0.0.0.0:0              LISTENING       4
  TCP    [::]:22               [::]:0                 LISTENING       4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .