自定义 SSH 端口上的 Git [英] Git On Custom SSH Port

查看:26
本文介绍了自定义 SSH 端口上的 Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 VPS 提供商建议我将 SSH 端口保留为他们默认分配的自定义端口号(不是 22).问题是虽然我知道我可以在创建远程配置时提供端口号,但在执行 git clone 时似乎我不能做同样的事情.我正在使用 gitolite,所以我克隆的命令如下所示:

My VPS provider recommends that I leave my SSH port to the custom port number they assign it by default (not 22). The thing is the while I know I can give the port number when create a remote config, it seems like I can't do the same when doing a git clone. I am using gitolite so I clone commands look like:

git clone git@mydomain.com:gitolite-admin

有没有办法将其转换为使用自定义 ssh 端口号?

Is there a way to covert this to using the custom ssh port number?

我还应该提到我在 Windows 上运行 cygwin.我看到多个地方说要将自定义端口添加到 ~/.ssh/config 文件中,例如

I should also mention I am running cygwin on windows. I have seen multiple places saying to add the custom port to the ~/.ssh/config file like

Host mydomain.com
    Port 12345

但是在 cygwin 中,该文件似乎不存在.

however in cygwin, that file does not seem to exist.

推荐答案

git clone ssh://git@mydomain.com:[port]/gitolite-admin

注意端口号应该没有方括号:[]

这篇关于自定义 SSH 端口上的 Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆