gpt4 book ai didi

git - ssh git clone超时

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

请帮助

我正在尝试通过SSH与linux ubuntu服务器上的git / github进行通信,同时还为SSH使用其他端口(不是22)。
当我尝试git clone时,我正在使用以下命令:
$ git clone -v [git@github.com:12345]:username/project-web.git myfolder
它挂了大约3分钟,然后我得到以下输出:

Cloning into 'myfolder'...
ssh: connect to host github.com port 12345: Connection timed out
fatal: Could not read from remote repository.

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

我的防火墙(UFW)设置正确;我可以成功SSH并连接到服务器。
这是我的UFW配置:
22                         DENY        Anywhere
12345/tcp ALLOW Anywhere
12345 ALLOW Anywhere
22/tcp DENY Anywhere
22 (v6) DENY Anywhere (v6)
12345/tcp (v6) ALLOW Anywhere (v6)
12345 (v6) ALLOW Anywhere (v6)
22/tcp (v6) DENY Anywhere (v6)

这是我的 ~/.ssh/config文件:
Host github.com
User git
Hostname github.com
IdentityFile ~/.ssh/deploy
IdentitiesOnly yes
Port 12345

和我的 /etc/ssh/sshd_config文件:
...
Port 12345
...

我已经尝试了其他相关的答案,但仍然没有运气:

git remote add with other SSH port

Git On Custom SSH Port

我究竟做错了什么?我使用了错误的命令吗?我已经尝试了上面相关答案中的许多命令,但还是没有运气。

最佳答案

简而言之,您无法更改远程服务正在侦听的端口。您试图在github.com上使用非默认端口12345。同样,在/etc/ssh/sshd_config中更改内容也完全不相关。它会更改sshd的行为(即,如果有人尝试对您的计算机使用ssh或git @ ssh)。

顺便说一句。您可以通过以下一种方法测试到github的ssh连接:

ssh -T git@github.com

请注意,任何非默认端口都将挂起连接( ssh -T git@github.com -p 12345)

关于git - ssh git clone超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59517368/

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