gpt4 book ai didi

linux - Git 在不同端口下运行 SSH

转载 作者:行者123 更新时间:2023-12-05 08:08:58 26 4
gpt4 key购买 nike

我们工作的服务器不使用 SSH 端口 22 - 他们使用 4 位端口。

现在,当我尝试使用诸如 git fetchgit pull 等命令时,它无法连接,因为它正在尝试使用我们的 4 位端口进行连接

[user@server]$ sudo git fetch --verbose
ssh: connect to host bitbucket.org port 2222: Network is unreachable
fatal: Could not read from remote repository.

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

所以我用SSH命令测试了一下

ssh -T git@bitbucket.org

得到了同样的结果,就是无法连接。所以我在 ~/.ssh/config

添加了一个主机
Host bitbucket.org
Port 22

和命令连接!然而,git 命令没有连接,我仍然遇到第一个错误。

我的 Remote 设置正确,因为它们在其他地方使用过,

origin  git@bitbucket.org:myrepo/repo.git (fetch)
origin git@bitbucket.org:myrepo/repo.git (push)

并且 SSH key 设置正确。

有谁知道如何解决这个问题,以便我可以通过 SSH 使用 git 命令?

感谢提供的任何帮助。

克里斯

最佳答案

编辑你的 ssh 配置文件:~/.ssh/config

Host bitbucket.org
Hostname altssh.bitbucket.org
Port 443

关于linux - Git 在不同端口下运行 SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44388643/

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