4

I've followed the Gitlab instructions to set up an SSH key.

After everything is completed, I test my settings with

ssh -T git@gitlab.com

but then I got an error with

git@gitlab.com: Permission denied (public key).

I also tried ssh -Tvvv git@gitlab.com to find out the problems, as below. But I can't figure out how to fix it, does anybody have an idea, or could share suggestions? Thank you very much!

OpenSSH_8.1p1, LibreSSL 2.7.3
.......
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/brandon/.ssh/id_rsa
debug3: no such identity: /Users/brandon/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /Users/brandon/.ssh/id_dsa
debug3: no such identity: /Users/brandon/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /Users/brandon/.ssh/id_ecdsa
debug3: no such identity: /Users/brandon/.ssh/id_ecdsa: No such file or directory
debug1: Offering public key: /Users/brandon/.ssh/id_ed25519 ED25519 SHA256:uOKjKpgEmnKqrFAS05Ccy8+B3Uw0kzSpurUpOgH0l3k
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
debug1: Trying private key: /Users/brandon/.ssh/id_xmss
debug3: no such identity: /Users/brandon/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
git@gitlab.com: Permission denied (publickey).

Thank you for your patience in reading my post.

Currycatlover
  • 99
  • 1
  • 1
  • 7
  • From the ssh logs, it used `/Users/brandon/.ssh/id_ed25519` to authenticate with Gitlab. Is this the same SSH public key you [added to your Gitlab account](https://docs.gitlab.com/ee/ssh/#adding-an-ssh-key-to-your-gitlab-account)? – Gino Mempin May 06 '20 at 23:57
  • Can you run ls -lh ~/.ssh/ to review your SSH keypair against https://docs.gitlab.com/ee/ssh/#review-existing-ssh-keys ? – Aleksey Tsalolikhin May 06 '20 at 20:34
  • 1
    What file should ssh be using to authenticate with github? In other words, what key did you set up with github? What file is that key stored in? – Kenster May 07 '20 at 01:59
  • @AlekseyTsalolikhin It states total 24 -rw------- 1 brandon staff 419B 5 7 02:16 id_ed25519 -rw-r--r--@ 1 brandon staff 108B 5 7 02:16 id_ed25519.pub -rw-r--r--@ 1 brandon staff 186B 5 7 02:17 known_hosts – Currycatlover May 07 '20 at 04:15
  • @GinoMempin Yes it is, but then I don't know why it doesn't work :( – Currycatlover May 07 '20 at 04:17
  • @Kenster I set up with id_ed25519.pub key, and it stored in /Users/brandon/.ssh – Currycatlover May 07 '20 at 04:18
  • Have you checked all the answers here: [How to solve Permission denied (publickey) error when using Git?](https://stackoverflow.com/q/2643502/2745495)? – Gino Mempin May 07 '20 at 04:23
  • @GinoMempin Thank you. Im still trying, but so far hasnt solve my problem yet. – Currycatlover May 07 '20 at 07:15

3 Answers3

3

Thank you, I solved it! Since its server is from our university so after changing ssh -T git@gitlab.com to ssh -T git@theuniversitylink.com it works.

I appreciate a lot for all the sharing and helps.

Currycatlover
  • 99
  • 1
  • 1
  • 7
1

set up with id_ed25519.pub key, and it stored in /Users/brandon/.ssh

Try first with a more classic rsa key, for testing!

ssh-keygen -t rsa -P "" -m PEM 

Copy the /Users/brandon/.ssh/id_rsa.pub to your GitLab SSH account settings, and check if ssh -T git@gitlab.com works.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I fixed it this way on macos:

ssh-add ~/.ssh/id_ed25519.pub
DevonDahon
  • 7,460
  • 6
  • 69
  • 114