title: gitlab runner ssh private key 644 file permission error
body: <p>When running a gitlab ci/cd pipeline, ssh gives 0644 bad permission error. Variable is stored as a file type in the settings&gt;variable section in gitlab.<br />
  .gitlab-ci.yml file looks like:</p>
  <pre><code>stages:
    - deploy
    
  before_script:
    - apt-get update -qq
    - apt-get install -qq git
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] &amp;&amp; echo -e &quot;Host *\n\tStrictHostKeyChecking no\n\n&quot; &gt; ~/.ssh/config'
  deploy_1:
    stage: deploy
    only:
      - master
    tags:
      - master
    script:
      - ssh -i $SSH_KEY user@ip &quot;mkdir -p runner_test&quot;
  
  deploy_2:
    stage: deploy
    only:
      - master
    tags:
      - master
    script:
      - ssh -i $SSH_KEY user@ip &quot;mkdir -p runner_test&quot;
  </code></pre>
  <p>Error:</p>
  <pre><code>$ ssh -i $SSH_KEY host@ip &quot;mkdir -p runner_test&quot;
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  Permissions 0644 for '/home/user/builds/gPnQDT8L/0/username/server.tmp/SSH_KEY' are too open.
  It is required that your private key files are NOT accessible by others.
  This private key will be ignored.
  Load key &quot;/home/user/builds/gPnQDT8L/0/username/server.tmp/SSH_KEY&quot;: bad permissions
  user@ip: Permission denied (publickey).
  Cleaning up file based variables
  </code></pre>
  <p>How do I change the private key permissions from 644 to 600 or 400.</p>