git - ssh git clone 超时
问题描述
请帮忙
我正在尝试通过 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
...
我已经尝试了这些其他相关的 SO 答案,但仍然没有运气:
我究竟做错了什么?我使用了错误的命令吗?我已经尝试了上面相关答案中的许多命令,但仍然没有运气。
解决方案
首先,如果您希望您的 ~/.ssh/config 被考虑在内,您的 SSH URL 应该是
github.com:username/project-web.git
(不git@
,不:12345
)
第二个 12345 仅适用于反向代理,然后将重定向到端口 22 或 443(当“在 HTTPS 端口上使用 SSH ”时)。
关于端口 443,主机名将是ssh.github.com
.
推荐阅读
- spring - 如何将密码文本与 bcrypt 哈希值进行比较?
- r - 如何应对线性混合模型(lme4)中的奇异拟合?
- pyqt5 - 是否有用于使用 QCombobox 从列表中进行多选的 Python-PyQt5 函数?
- python - Kubernetes 未记录打印
- mysql - 安装数据卷时,Windows 10 Docker MySql:5.6 容器未启动
- css - 向线性渐变填充div添加双边框也会为边框着色
- php - DB2 存储过程的输出为空
- angular - 如果 HTTP 错误代码为 500,则 Angular 重新尝试 API 请求
- freemarker - Freemarker - 用户定义指令调用的动态名称
- python - 在张量流中计算新状态(RNN)相对于模型参数(包括输入的 CNN)的梯度;tf.gradient 返回无