【问题标题】:GitLab SSH Permission denied (publickey)GitLab SSH 权限被拒绝(公钥)
【发布时间】:2021-04-09 03:46:36
【问题描述】:

我已按照 Gitlab 的说明设置了 SSH 密钥。

一切都完成后,我测试我的设置

ssh -T git@gitlab.com

但后来我遇到了一个错误

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

我也试过ssh -Tvvv git@gitlab.com来找出问题,如下。 但我不知道如何解决它,有没有人有想法,或者可以分享建议? 非常感谢!

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).

感谢您耐心阅读我的帖子。

【问题讨论】:

  • 你能运行 ls -lh ~/.ssh/ 来检查你对docs.gitlab.com/ee/ssh/#review-existing-ssh-keys的SSH密钥对吗?
  • 从 ssh 日志中,它使用 /Users/brandon/.ssh/id_ed25519 向 Gitlab 进行身份验证。这是与added to your Gitlab account 相同的 SSH 公钥吗?
  • ssh 应该使用什么文件来通过 github 进行身份验证?换句话说,你用 github 设置了什么键?该密钥存储在什么文件中?
  • @AlekseyTsalolikhin 它说总共 24 -rw------- 1 名布兰登员工 419B 5 7 02:16 id_ed25519 -rw-r--r--@ 1 名布兰登员工 108B 5 7 02 :16 id_ed25519.pub -rw-r--r--@ 1 布兰登员工 186B 5 7 02:17 known_hosts
  • @GinoMempin 是的,但是我不知道为什么它不起作用:(

标签: git macos ssh gitlab


【解决方案1】:

谢谢,我解决了! 由于它的服务器是我们大学的所以在改变之后 ssh -T git@gitlab.comssh -T git@theuniversitylink.com 它有效。

非常感谢所有的分享和帮助。

【讨论】:

  • ssh -Tv 是否显示 id_rsa 是否被接受?或id_ed25519?
  • @VonC 是的!
【解决方案2】:

使用 id_ed25519.pub 密钥设置,并将其存储在 /Users/brandon/.ssh 中

首先尝试使用更经典的 rsa 密钥进行测试!

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

将 /Users/brandon/.ssh/id_rsa.pub 复制到您的 GitLab SSH 帐户设置,并检查 ssh -T git@gitlab.com 是否有效。

【讨论】:

  • 您好,谢谢!我试过了,但公钥的结果还是一样(拒绝)
  • @BrandonTW 您是否将id_rsa.pub 的内容正确注册到您的帐户?作为一条连续线?
【解决方案3】:

我在 macos 上是这样修复的:

ssh-add ~/.ssh/id_ed25519.pub

【讨论】:

    猜你喜欢
    • 2019-03-08
    • 1970-01-01
    • 2019-11-24
    • 2014-11-08
    • 2019-03-11
    • 1970-01-01
    • 1970-01-01
    • 2019-08-20
    • 2016-08-13
    相关资源
    最近更新 更多