Harvey
Harvey

Reputation: 304

Accidentally enabled Firewall - SSH connections to port 22 are refused

I have a remote Azure Ubuntu VM where firewall wasn't enabled. While changing the configurations I accidentally enabled the firewall but forgot to allow port 22 for SSH. Only port 443 is allowed in firewall.

It's a very lame mistake but I cannot SSH into my VM. The SSH connection is refused every time. Is there a way out of this?

Upvotes: 1

Views: 847

Answers (4)

MEB
MEB

Reputation: 53

Since this seems to be the top hit for this issue, I thought that I would update these posts. Azure now has, what they call, a 'Serial console'. It can be found under the 'Help' dropdown on the side menu. Click on 'Serial console' and login to your user. My non-root root user had enough permissions. Then use the 'sudo ufw disable' command. This will stop and disable the firewall. Now go and verify via your ssh command that you now have access.

Upvotes: 0

garbrad
garbrad

Reputation: 241

You could use the "CustomScriptExtension" VM extension to run the command necessary to repair the firewall rule.

Upvotes: 0

ranieuwe
ranieuwe

Reputation: 2296

Unfortunately currently (August 2016) it is not possible to do that on Azure. The only way to fix it would be to download the VHDs for the VM, boot them locally in Hyper-V, VMConnect to them, fix the problem and upload them back to Azure.

It is an often requested feature here: https://feedback.azure.com/forums/216843-virtual-machines/suggestions/3761826-virtual-machine-console-access

Upvotes: 1

cjdp
cjdp

Reputation: 81

Most VM providers provide a form of console access via the control panel where your VM instances are managed. This usually requires you to log into the control panel. The console then allows access the same way a screen and keyboard would. You can use this to open port 22 in your firewall.

Upvotes: 0

Related Questions