Nginx refuses ssh, locked outside

Viewed 696

I deployed a ubuntu VM in the Azure microsoft cloud. I might have forgotten to allow ssh connections when I set up the firewall. So now whenever I try to ssh in my VM I get a ssh timeout. I checked using nmap and see that only the http and https ports are open. Is there any way to reconfigure the firewall so I can allow ssh. Note its not azure thats blocking the ssh connection, its my nginx server itself. I set nginx to auto restart when restarting the VM so that won't be a solution.

In the worst case I would just delete the VM and make a new one, but this would mean I have to reinstall everything. thx for helping

Edit I will just make a new VM.

2 Answers

There is a panel inside the azure portal where you can execute a remote command. I used this to execute sudo ufw allow ssh, now I can connect back to the vm!

Since the Run command option might not be available for your resource group and for your access rights, another possibility is to use Azure CLI command-line tool: if you have it installed, you need to log in via az login, and then you need to type:

az vm run-command invoke -g YourResourceGroup \
 -n YourVM_Name --command-id RunShellScript \
--scripts "sudo ufw allow ssh"
Related