V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
rimutuyuan
V2EX  ›  问与答

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

  •  
  •   rimutuyuan · 2022-09-06 20:56:49 +08:00 · 751 次点击
    这是一个创建于 820 天前的主题,其中的信息可能已经有所发展或是发生改变。
    前提

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

    zshrc 中配置了 ssh-agent plugin

    ---

    clone 仓库时提示

    [email protected]: 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 [email protected] 提示
    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: [email protected] 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.
    [email protected]: Permission denied (publickey).


    (开始生成了一个 rsa 密钥对,相同错误,后来把.ssh 目录清空后重新生成的 ed25519 密钥对,gitlab 上也同步重置)
    2 条回复    2022-09-07 14:33:55 +08:00
    ETiV
        1
    ETiV  
       2022-09-06 21:31:22 +08:00 via iPhone
    是只有你自己的 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
        2
    magichacker  
       2022-09-07 14:33:55 +08:00
    公司运维可能做了限制,我们公司就是这样
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5752 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 02:50 · PVG 10:50 · LAX 18:50 · JFK 21:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.