Answers: <p>Most probably, you are using the wrong account.</p>
  <p>Find out which one you are currently using in CLI:</p>
  <pre><code>gcloud config configurations list
  gcloud auth list
  </code></pre>
  <p>If the selected configuration is wrong, fix it and then retry with <code>gcloud compute firewall-rules create</code>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-12-03T22:30:20.147Z
Answers: 2021-12-03T22:30:20.147Z
Answers: xy2
Body: <p>Is there anyway to allow the ports from CLI? <br />
  I have an instance in GCP and I have installed a service which by default runs on <code>Port:8080</code>. I know there is an option to change the firewall rules to allow ports from the GCP dashboard but <strong>I'm wondering if there is any way to allow the required ports from the CLI</strong><br />
  In my case I'm using <code>Git Bash</code> rather than the native <code>GCP Cloud Console</code> <br />
  I have seen the documentation to allow ports from command line <a href="https://cloud.google.com/sdk/gcloud/reference/compute/firewall-rules/create" rel="nofollow noreferrer">GCP Firewall-rules-from CLI</a> but this is throwing a <code>ERROR</code> since I'm using the <code>Git Bash</code>. <br />
  Here is the error log:</p>
  <pre><code>[mygcp@foo~]$ gcloud compute firewall-rules create FooService --allow=tcp:8080 --description=&quot;Allow incoming traffic on TCP port 8080&quot; --direction=INGRESS
  Creating firewall...failed.
  ERROR: (gcloud.compute.firewall-rules.create) Could not fetch resource:
   - Request had insufficient authentication scopes.
  
  [mygcp@foo~]$ gcloud compute firewall-rules list
  ERROR: (gcloud.compute.firewall-rules.list) Some requests did not succeed:
   - Request had insufficient authentication scopes.
  </code></pre>
  <p>Is there any option to allow required ports directly from the Git Bash CLI?</p>
  
Tags: <google-cloud-platform><bash><ports><firewall>
Title: How to modify/allow firewall rules of a GCP instance directly from the CLI?
UserDisplayName: AV Reddy
ThreadText: # How to modify/allow firewall rules of a GCP instance directly from the CLI?
  
  (Asked by: username_0 on 2021-11-28)
  
  Is there anyway to allow the ports from CLI?   
  I have an instance in GCP and I have installed a service which by default runs on `Port:8080`. I know there is an option to change the firewall rules to allow ports from the GCP dashboard but **I'm wondering if there is any way to allow the required ports from the CLI**  
  In my case I'm using `Git Bash` rather than the native `GCP Cloud Console`   
  I have seen the documentation to allow ports from command line [GCP Firewall-rules-from CLI](https://cloud.google.com/sdk/gcloud/reference/compute/firewall-rules/create) but this is throwing a `ERROR` since I'm using the `Git Bash`.   
  Here is the error log:
  
  ```
  [mygcp@foo~]$ gcloud compute firewall-rules create FooService --allow=tcp:8080 --description="Allow incoming traffic on TCP port 8080" --direction=INGRESS
  Creating firewall...failed.
  ERROR: (gcloud.compute.firewall-rules.create) Could not fetch resource:
   - Request had insufficient authentication scopes.
  
  [mygcp@foo~]$ gcloud compute firewall-rules list
  ERROR: (gcloud.compute.firewall-rules.list) Some requests did not succeed:
   - Request had insufficient authentication scopes.
  
  ```
  
  Is there any option to allow required ports directly from the Git Bash CLI?
  
  **Tags:** google-cloud-platform, bash, ports, firewall
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-03. Score: 2
  
  Most probably, you are using the wrong account.
  
  Find out which one you are currently using in CLI:
  
  ```
  gcloud config configurations list
  gcloud auth list
  
  ```
  
  If the selected configuration is wrong, fix it and then retry with `gcloud compute firewall-rules create`.
  
  
  ---
  
  