gpt4 book ai didi

git - 如何使git clone与ssh一起使用?

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

我是一个gitnewbie,试图用ssh克隆我的githubrepo。我遵循以下步骤:
https://help.github.com/articles/generating-an-ssh-key/

在代理环境中工作使自己感到直觉,这可能与此有关。当我去:git clone git@github.com:myuser / myrepo.git时,出现此错误:

ssh: connect to host github.com port 22: Connection timed out

如何解决此错误?

最佳答案

您可以用解决任何ssh问题的相同方法来修复它。从方程式中删除Git,然后尝试使用ssh登录。如果有效,您应该会看到类似这样的信息。

$ ssh git@github.com
PTY allocation request failed on channel 0
Hi schwern! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

如果它不起作用,则需要调试ssh session 。通常,您可以使用 ssh -v来执行此操作(也可以添加更多 -v以获得更多的详细程度)。
$ ssh -v foo@example.com
OpenSSH_7.1p2, OpenSSL 1.0.2e 3 Dec 2015
debug1: Reading configuration data /opt/local/etc/ssh/ssh_config
debug1: Connecting to example.com [93.184.216.34] port 22.

如果此时挂起,则可能根本无法连接到主机,或者没有SSH服务器监听端口22,或者该端口已被防火墙阻止。

由于这是Github,肯定有一个ssh服务器并且正在为我工​​作,因此我怀疑最后一个:您在防火墙后面。您可以尝试通过ssh到其他地方进行测试。

在这种情况下,请使用VPN绕过防火墙,或者尝试使用HTTPS连接。
git clone https://github.com/myuser/myrepo.git

关于git - 如何使git clone与ssh一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35075084/

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