gpt4 book ai didi

ssh - 通过ssh从gitlab进行git克隆会导致 "Permission denied (publickey)"

转载 作者:行者123 更新时间:2023-12-02 20:49:25 28 4
gpt4 key购买 nike

如果创建了一个新的 ssh key ,请将公钥复制并粘贴到 gitlab 项目,并在 ~/.ssh 中创建一个 conifg 文件...

我仍然无法克隆该项目(我不是所有者,但我被添加为用户)

这就是我尝试的(当然我使用的是正确的路径):

git clone -v git@gitlab.foo.bar.com:bla/blub.git

这给了我

cloning to 'blub' ...
Permission denied (publickey).
fatal: couldn't read from Remote-Repository

然后我尝试了以下方法

ssh -vT -i ~/.ssh/gitlab git@gitlab.foo.bar.com:bla

这给了我

OpenSSH_7.2p2, OpenSSL 1.0.2j-fips  26 Sep 2016
debug1: Reading configuration data /user/me/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: Connecting to gitlab.com [52.167.219.168] port 22.
debug1: Connection established.
debug1: identity file /user/me/.ssh/gitlab type 1
debug1: key_load_public: No such file or directory
debug1: identity file /user/me/.ssh/gitlab-cert type -1
debug1: identity file /user/me/.ssh/gitlab type 1
debug1: key_load_public: No such file or directory
debug1: identity file /user/me/.ssh/gitlab-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to gitlab.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw
debug1: Host 'gitlab.com' is known and matches the ECDSA host key.
debug1: Found key in /user/me/.ssh/known_hosts:26
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /user/me/.ssh/gitlab
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /user/me/.ssh/gitlab
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我真的不明白...通过 http 进行克隆和拉取效果非常好。SSH 则不然。

有什么提示吗?

编辑:~/.ssh 中的配置文件如下所示(建议 here )

Host gitlab.foo.bar.com
RSAAuthentication yes
IdentityFile ~/.ssh/gitlab

私钥名为 gitlab,公钥名为 gitlab.pub

编辑2:~/.ssh 的权限设置为 700并将 ~/.ssh/* 设置为 600

最佳答案

尝试以下操作。这对我有用。

eval "$(ssh-agent -s)"
ssh-add

关于ssh - 通过ssh从gitlab进行git克隆会导致 "Permission denied (publickey)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49779711/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com