title: How to fix Permission denied (publickey,password) in gitlab Ci/CD?
body: <p>I have below simple script in .gitlab-cl.yml file:</p>
  
  <pre><code>build_deploy_stage:
    stage: build
    environment: Staging
    only:
      - master
    script:
  
      - mkdir -p ~/.ssh
  
      - echo "$PRIVATE_KEY" &gt;&gt; ~/.ssh/id_dsa
      - cat ~/.ssh/id_dsa
      - chmod 600 ~/.ssh/id_dsa
      - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" &gt; ~/.ssh/config
      - cat ~/.ssh/config
      - scp   myfile.js user@example.com:~
  </code></pre>
  
  <p>But I get this error when job is run, executing the last line (scp command):</p>
  
  <pre><code>Warning: Permanently added 'example.com' (ECDSA) to the list of known hosts.
  Permission denied, please try again.
  Permission denied, please try again.
  Permission denied (publickey,password).
  </code></pre>
  
  <p>I spent whole day but could not fix it. I verified that $PRIVATE_KEY exists.  I generated key pair while logged into example.com copying the generated private to PRIVATE_KEY variable on gitlab.
  How to fix this problem?</p>
  
  <p>Note that it is dsa key.</p>