配置完 gitlab ssh key 后,在 mac 下仍不能使用公钥访问

2022-09-06 20:56:49 +08:00
 rimutuyuan
前提

使用 ssh-keygen -t ed25519 -C "<comment>" 命令生成密钥对,并将 /home/.ssh/id_ed25519.pub 内容添加到 gitlab 的用户 ssh 设置中

zshrc 中配置了 ssh-agent plugin

---

clone 仓库时提示

git@xxxx.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


---

执行 ssh -Tvvv git@xxxx.com 提示
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: Offering public key: /Users/minchen/.ssh/id_ed25519 ED25519 SHA256:gvJaTnUsmo4yy2inbG5urOrZfr8wewE/qA3qm3A+OIQ agent
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: Offering public key: west.side@foxmail.com RSA SHA256:O14ly7v/7CyshiZcSla3Zd0v8Mg78jKpfGLK3btaRr8 agent
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/minchen/.ssh/id_rsa
debug3: no such identity: /Users/minchen/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /Users/minchen/.ssh/id_dsa
debug3: no such identity: /Users/minchen/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /Users/minchen/.ssh/id_ecdsa
debug3: no such identity: /Users/minchen/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/minchen/.ssh/id_ecdsa_sk
debug3: no such identity: /Users/minchen/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /Users/minchen/.ssh/id_ed25519_sk
debug3: no such identity: /Users/minchen/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /Users/minchen/.ssh/id_xmss
debug3: no such identity: /Users/minchen/.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@xxxx.com: Permission denied (publickey).


(开始生成了一个 rsa 密钥对,相同错误,后来把.ssh 目录清空后重新生成的 ed25519 密钥对,gitlab 上也同步重置)
743 次点击
所在节点    问与答
2 条回复
ETiV
2022-09-06 21:31:22 +08:00
是只有你自己的 key 不好使,还是任何人的都不好使?

如果是后者、而且是你自己部署的,注意一下这个 host 的 22 是被谁监听(应该是 gitlab 的 ssh ,而不是系统的)

如果只有你自己不行,macOS 下的 ssh-add 有一个-K 参数,可以把私钥添加进系统 keychain ,可能你需要这么操作下
可以参考下这个: https://docs.github.com/en/enterprise-cloud@latest/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
magichacker
2022-09-07 14:33:55 +08:00
公司运维可能做了限制,我们公司就是这样

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/878179

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX