title: How to dynamically change the host in the SSH config file?
body: <p>I'm trying to connect to a GCP instance, which changes its public IP every time it's restarted. To get the IP dynamically I use this <code>gcloud</code> command:</p>
  <pre><code>gcloud compute instances describe &lt;vm-name&gt; --zone europe-west --format='get(networkInterfaces[0].accessConfigs[0].natIP)'
  </code></pre>
  <p>Then I have this <code>ssh config</code> file:</p>
  <pre><code>Host MyHost
      ProxyCommand ~/.ssh/vm-connect
  </code></pre>
  <p>which points to a script <code>vm-connect</code> with the following contents</p>
  <pre><code>#!/bin/bash
  get_host() {
      gcloud compute instances describe &lt;vm-name&gt; --zone europe-west1-b --format='get(networkInterfaces[0].accessConfigs[0].natIP)'
  }
  
  ssh minikf@$(get_host)
  </code></pre>
  <p>If I only run the script it connects to the VM successfully. But if I run <code>ssh MyHost</code> it gives me:</p>
  <pre><code>Pseudo-terminal will not be allocated because stdin is not a terminal.
  -bash: line 1: SSH-2.0-OpenSSH_8.2p1: command not found
  </code></pre>