title: Access GitHub repo from CloudBuild
body: <p>I am using Google CloudBuild as a CI server. It is using a mirror-repo of my GitHub repo to detect/pull changes, which works perfectly fine.</p>
  <p>My problem is that once CloudBuild has successfully run all my tests, I want it to add a tag to my repo. I am using the <code>gcr.io/cloud-builders/git</code> container, but I can't push tags directly since this is only connected to the mirrored repo. So, to get around this, I am using a shell script to clone the repo directly from Github to actually create a tag.</p>
  <p>When I try to access Github from Cloudbuild, I get the following error message:</p>
  <pre class="lang-sh prettyprint-override"><code>Step #3: debug1: read_passphrase: can't open /dev/tty: No such device or address
  Step #3: Host key verification failed.
  Step #3: fatal: Could not read from remote repository.
  Step #3: 
  Step #3: Please make sure you have the correct access rights
  Step #3: and the repository exists.
  </code></pre>
  <p>Here is the script I am using (it just tests github access):</p>
  <pre class="lang-sh prettyprint-override"><code>#!bin/sh
  
  # Copy private key to ~/.ssh directory
  cp ./path/to/my/key ~/.ssh/github
  chmod 600 ~/.ssh/github
  
  # Create SSH config file
  cat &gt;~/.ssh/config &lt;&lt;EOL
  Host github.com
    HostName github.com
    AddKeysToAgent yes
    IdentityFile ~/.ssh/github
  EOL
  chmod 600 ~/.ssh/config
  
  # Add key to agent
  eval &quot;$(ssh-agent -s)&quot;
  ssh-keyscan github.com &gt;&gt; ~/.ssh/known_hosts
  ssh-add -k ~/.ssh/github
  
  # Set GIT config
  git config --global user.name &quot;myusername&quot;
  git config --global user.email &quot;myusername@users.noreply.github.com&quot;
  
  # Test authentication with Github
  ssh -T git@github.com
  </code></pre>
  <p>Another relevant part of the debug logs is this:</p>
  <pre class="lang-sh prettyprint-override"><code>Step #3: debug1: Reading configuration data /etc/ssh/ssh_config
  Step #3: debug1: /etc/ssh/ssh_config line 1: Applying options for github.com
  </code></pre>
  <p>It seems to be reading from <code>/etc/ssh/ssh_config</code> instead of the <code>~/.ssh/config</code> file I created.</p>
  <p>What am I doing wrong?</p>