Problem with ssh publickey login to gitlab from git client

Symptom, can’t login to gitlab with public key. Logs look something like this:

debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: ED25519 SHA256:uLISVsQgduUdLa_h2OgDJ3G1Va42QUaNlD9sIq7ScF0 /home/media/.ssh/gitlab2
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
ltburch@gitlab.com: Permission denied (publickey).

I spent quite a while with this and never saw a note about it so I figured I would mention it in the hopes to save others some time.

When you SSH login to gitlab when setting up publickey authentication you do not log in with your userid. This is notable because it is not typical ssh behavior, typical behavior has you login as your userid and provide your keyfile to ssh, not so with gitlab

Wrong:

ssh -T myuserid@gitlab.com

Correct (for everybody):

ssh -T git@gitlab.com

Git uses the single ID and switches to your personal context based on the fingerprint of the SSH key you are providing (that it recognizes). Note, recognizing the fingerprint is insufficient - obviously you need the full proper key as well.

I hope this helps, I had even setup my own ssh server with the same key and could show that I had the PKI working but gitlab still wouldn’t budge.