1

I have an Ubuntu server on google compute engine that i have allowed ufw on but forgot to allow port 22 for ssh connections and now I cannot access it

  • Any idea how can I reverse that?

I also tried to connect using google serial console but i can't remember my instance username and password.

  • Where are these set?
GalloCedrone
  • 4,869
  • 3
  • 25
  • 41
Aya Mohamed
  • 39
  • 1
  • 4

2 Answers2

3

This answer from Server Fault solved the problem for me . Use any of the 2 methods. I used the first:

  1. Method 1: Add startup script on the GCP VM's instance settings page to disable ufw

    #! /bin/bash
    /usr/sbin/ufw disable
    
  2. Method 2: Attach the boot disk to another instance and modify the file /etc/ufw/ufw.conf

See link for detailed instructions

Musili Alfred M.
  • 3,085
  • 1
  • 15
  • 12
2

I would suggest you to run a startup script and set username/password in order to access through serial console or directly to modify the ufw writing down in the script the commands you would have used.

Note that the startup script is run as root.

GalloCedrone
  • 4,869
  • 3
  • 25
  • 41