title: GCP Connection Failed - SSH - We are unable to connect to the VM on port 22
body: <p>Since I received a email warning letter from google says "Action required: Critical problem with My First Project" saying my server has some abnormal outgoing activity , I tried to implemented ufw in my debian server.</p>
  
  <p>For my ufw setting, I've done the following:</p>
  
  <pre><code>sudo ufw default deny incoming 
  sudo ufw default deny outgoing
  sudo ufw allow ssh
  sudo ufw allow 22
  sudo ufw allow http
  sudo ufw allow https
  </code></pre>
  
  <p>After I restart my server , I can't connect to my server with the error "Connection Failed: We are unable to connect to the VM on port 22. Learn more about possible causes of this issue."</p>
  
  <p>I followed the following instruction <a href="https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh" rel="nofollow noreferrer">https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh</a> but it still not working:</p>
  
  <ol>
  <li>I tried gcloud to create default-allow-ssh 
  <a href="https://i.stack.imgur.com/jxEcw.png" rel="nofollow noreferrer">my firewall-rules list picture</a></li>
  <li>I tried to use serial console to login but I haven't set password to my root account so I can't login. </li>
  <li>I tried to add "/usr/sbin/ufw disable" to startup-script in Custom metadata and restart server many times but it seems the command is not executed so still not working
  <a href="https://i.stack.imgur.com/oE9ip.png" rel="nofollow noreferrer">my gcp startup-script picture</a></li>
  </ol>