Cannot connect to remote host

I’ve been racking my brain about this all day.

I have a gitlab setup at and a staging server at

Now, I’ve followed the instruction at and I’ve:

  • Generated an SSH key at (on the server, not the runner)
  • Copied the key at ~/.ssh/id_rsa to a variable called SSH_PRIVATE_KEY
  • Copy/pasted the before_scripts from the above URL.

This works (as in doesnt throw any issues). I also:

To the before_script.

I then copied the file at ~/.ssh/" then shelled into the server and added it to ~/.ssh/authorized_keys

I gets all the way to opening an SSH connection then fails with Permission denied (publickey).

If you haven’t yet, you should verify that the SSH key is working properly by adding it to your shell user and logging in with it, just to make sure nothing weird is going on.

Also, check your auth.log (if you haven’t already. It might give you more specifics about what is going on). And finally, if none of that helps you to get it working, verify that the user has the proper permissions. If none of these work, hopefully a more knowledgeable person will be around shortly. Good luck!