简体   繁体   English

无法使用 SSH 克隆 Github 回购协议

[英]Can not clone Github repo using SSH

I have freshly installed Linux Manjaro with Plasma Desktop.我刚刚安装了带有 Plasma Desktop 的 Linux Manjaro。 Cloning my repos from Github using SSH gives me some trouble.使用 SSH 从 Github 克隆我的存储库给我带来了一些麻烦。 I tried我试过

[andreas@Bixente ~]$ ssh-add -l
Could not open a connection to your authentication agent.
[andreas@Bixente ~]$ eval "$(ssh-agent -s)"
Agent pid 5346
[andreas@Bixente ~]$ ssh-add -l
The agent has no identities.
[andreas@Bixente ~]$ ssh-add ~/.ssh/github
Identity added: /home/andreas/.ssh/github (andreas@Bixente)
[andreas@Bixente ~]$ git clone git@github.com:Username/project.git ~/TestDir
Cloning into '/home/andreas/TestDir'...
Connection closed by 140.82.121.3 port 22
fatal: Could not read from remote repository.

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

What am I doing wrong?我究竟做错了什么? I am sure I put the key on Github. Furthermore, it seems like I have to do this after every restart.我确信我把钥匙放在了 Github 上。此外,似乎每次重启后我都必须这样做。

Edit: Nothing really works.编辑:没有什么真正有效。 I followed step by step, even created and used another key with default name.我一步一步地跟着,甚至创建并使用了另一个具有默认名称的密钥。 Still no solution.仍然没有解决办法。

[andreas@Bixente .ssh]$ ssh-add id_ed25519
Identity added: id_ed25519 (andreas@Bixente)
[andreas@Bixente .ssh]$ ssh -Tvvv git@github.com
OpenSSH_9.1p1, OpenSSL 3.0.7 1 Nov 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/andreas/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/andreas/.ssh/known_hosts2'
debug2: resolving "github.com" port 22
debug3: resolve_host: lookup github.com:22
debug3: ssh_connect_direct: entering
debug1: Connecting to github.com [140.82.121.3] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: connect to address 140.82.121.3 port 22: Connection timed out
ssh: connect to host github.com port 22: Connection timed out

Edit: I followed the exact same steps to my friends machine (MacBook Air) without any problems.编辑:我对我朋友的机器(MacBook Air)执行了完全相同的步骤,没有任何问题。 But I recognized, I was never asked to add Github to known_hosts.但我意识到,我从未被要求将 Github 添加到 known_hosts。

Check here , to get an idea on how the cloning process works. 在此处查看,以了解克隆过程的工作原理。

  • ensure that you are providing public key in the GitHub console ensure that you are providing public key in the GitHub console

  • check the connection using ssh -T git@github.com , in case of any errors check here使用ssh -T git@github.com检查连接,如果有任何错误检查这里

  • verify that public and private keys are present in the .ssh folder and optionally known_hosts验证公钥和私钥是否存在于.ssh文件夹和可选的known_hosts

  • debug using ssh -vvv git@github.com使用ssh -vvv git@github.com进行调试

That should resolve your issue.那应该可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM