我想通过ssh将git存储库克隆到我的ubuntu,但是我收到以下错误:
权限被拒绝(publickey)。致命:无法从远程读取 库中。
我的公钥已添加到代理中,我已在Windows上使用它,但是当我在Linux上尝试它时,它无效。
答案 0 :(得分:1)
每个远程git
repo都与将在远程系统上执行的某些登录相关联,以便访问repo目录。此登录尝试失败,因为(a)您的SSH密钥未被识别(或者,您的计算机上的SSH代理未正确提供),并且(b)< / em>密码登录不是替代方案。
要帮助诊断问题,请从图片中删除git
。使用git remote -v
查找正在尝试的用户/主持人,并尝试直接ssh
登录该帐户。 (它会失败。)像对任何类似的仅ssh问题一样诊断问题。一旦您能够登录,您就可以克隆。
答案 1 :(得分:0)
Git比ssh
(在你的情况下)或https
做得更好。通常使用底层命令而不是通过Git来调试连接问题通常会更好,您可以获得更好的诊断并且可以使用正常的ssh调试技术。
尝试使用ssh -v
(详细模式下的ssh)连接到同一个遥控器。如果是git clone git@github.com:schwern/dotfiles.git
,请尝试ssh -v git@github.com
。只是用户和主机。是的,用户应该是git
,Github通过你的ssh密钥识别你。
你应该得到这样的东西......
$ ssh -v git@github.com
OpenSSH_7.2p1, OpenSSL 1.0.2h 3 May 2016
debug1: Reading configuration data /Users/schwern/.ssh/config
debug1: Reading configuration data /opt/local/etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/schwern/.ssh/id_rsa type -1
...a whole lot of ssh looking for your ssh keys...
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/schwern/.ssh/github
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/schwern/.ssh/id_rsa
debug1: Trying private key: /Users/schwern/.ssh/id_dsa
...a whole lot of trying ssh keys...
debug1: No more authentication methods to try.
Permission denied (publickey).
重要的部分是它寻找和提供钥匙的地方。如果你没有在那里看到你的Github密钥,那么你需要找出原因。如果你确实在那里看到了你的Github密钥,那么你应该检查一下Github认为你的密钥是什么。
你想看到的是这个。
$ ssh -v git@github.com
OpenSSH_7.2p1, OpenSSL 1.0.2h 3 May 2016
debug1: Reading configuration data /Users/schwern/.ssh/config
debug1: Reading configuration data /opt/local/etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/schwern/.ssh/id_rsa type -1
...ssh finding your keys...
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/schwern/.ssh/github
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.253.113]:22).
...Yay! You're in!...
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Requesting authentication agent forwarding.
PTY allocation request failed on channel 0
Hi schwern! You've successfully authenticated, but GitHub does not provide shell access.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
Transferred: sent 2936, received 1796 bytes, in 0.2 seconds
Bytes per second: sent 13380.7, received 8185.2
debug1: Exit status 1