Why is Trellis so unpredictable? Failed to connect to the host via ssh: Permission denied (publickey)

Are you able to try to rule out GitLab as a compounding factor by using GitHub for these tests?

It seems to me that that basic troubleshooting steps apply: if the problem (according to the error) is GitLab, then try replacing GitLab with something else to confirm the problem lies there.

You could also confirm that GitLab has your SSH key, and that SSH forwarding is working. You mentioned you’re on a Mac; MacOS security settings require that you type ssh-add -k to forward your local ssh key when connecting to a remote server.

However! All the remote servers involved (your DO droplet and GitLab) have to agree to accept that forwarded key.

Since you said you created a new user, and regenerated your ssh key at least once (not strictly necessary because it means you’ll need to add that new key to both DO and GitLab; ssh key problems shouldn’t require regenerating your key; you should only need to make sure the remote servers you’re talking to are willing to accept your key whatever it is) you may simply be running into a key mismatch.

If this is the case, everything might actually be working as intended. Key mismatches should prevent deploys. Can you confirm that your DO droplet has your (current, new!) ssh key added to it, and that GitLab also accepts that key? You can test the latter by trying to clone your GitLab repo locally over ssh.

4 Likes