title: GCloud ssh cannot connect when called
body: <p>I have testing code in Go, which sets up a state on a Compute Engine Instance (and don't want to expose the ports).
  Since there seems to be no easy way of doing this in Golang directly, I utilize <code>gcloud</code>:</p>
  <pre class="lang-golang prettyprint-override"><code>func TestMe(t *testing.T) {
    cmd := exec.Command(&quot;gcloud&quot;, &quot;compute&quot;, &quot;ssh&quot;, &quot;--project&quot;, &quot;foo&quot;, &quot;--tunnel-through-iap&quot;, &quot;--zone&quot;, &quot;europe-west1-z&quot;, &quot;bar&quot;, `--ssh-flag=&quot;-T&quot;`, &quot;--&quot;, &quot;echo WOW&quot;)
    cmd.Env = os.Environ()
    out, err := cmd.CombinedOutput()
    println(string(out))
    t.Fatal(err)
  }
  </code></pre>
  <p>When running <code>go test</code>, <code>cmd</code> outputs:</p>
  <pre><code>bash: myuser@compute.123456789: command not found
  </code></pre>
  <p>The compute instance is correct - but something fails when trying to access the compute instance. The same gcloud command works in bash (even for non-interactive). I assume there is something different in the Golang environment.</p>