title: SSH Connection Inside GitLab Runner CI Pipeline Not Able to Verify Host Key
body: <p>I am attempting to have a stage in my GitLab CI pipeline checkout a private GitLab repository but I can't seem to get SSH authentication to work.</p>
  <p>On my local machine I created a SSH private/public keypair. I am using my local machine only for creating that keypair and am not using it as a server/GitLab runner.</p>
  <p>I have the public key added to my GitLab repository as a Deploy Key. I have the private key as a protected variable called <code>$GIT_SSH_PRIV_KEY</code>.</p>
  <p>The code below is in a stage and I am just testing right now to see if <code>ssh -T git@gitlab.com</code> will authenticate properly.</p>
  <pre><code>    stage: git_merge
      before_script:
          - apt-get update -qq
          - apt-get install openssh-client -qq
          - eval $(ssh-agent -s)
          - echo &quot;$GIT_SSH_PRIV_KEY&quot; | tr -d '\r' | ssh-add - &gt; /dev/null
          # - ssh-add &lt;(echo &quot;$GIT_SSH_PRIV_KEY&quot;)
          - mkdir -p ~/.ssh &amp;&amp; touch ~/.ssh/known_hosts
          - echo $&quot;SSH_KNOWN_HOSTS&quot; &gt;&gt; ~/.ssh/known_hosts
          - chmod 644 ~/.ssh/known_hosts
      script:
          - ssh -T git@gitlab.com
  </code></pre>
  <p>The error I receive in the pipeline is <code>Host Key verification failed</code> so I am not sure where my issue is at currently.</p>