Log in to Google Compute Engine instance if ssh port is disabled by firewall

One of our developers forgot to add port 22 into allow list of firewall (Ubuntu Ufw). There are 2 way to resolve this problem:

  1. If you still have user/password of that VM, connect to the VM via Serial Port then login to open ssh port again.  
  2. If you don't have user/password (My case), add a Startup Script to that VM then restart it. Start up script responsible is open port when the VM starts.  
Then ... You have your VM back, Cheer!