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

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

问题描述

我的VPS提供商建议我将我的SSH端口留给他们默认分配的自定义端口号(不是22)。事情是,虽然我知道我可以给端口号,当创建一个远程配置,似乎我做不了相同的做一个git克隆。我使用gitolite所以我克隆命令看起来像:

  git clone git@mydomain.com:gitolite-admin 
有没有办法将其转换为使用自定义ssh端口号?


$ b

$ b

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

  Host mydomain.com 
Port 12345

,该文件似乎不存在。

解决方案

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

请注意,没有方括号:[]


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

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

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

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

解决方案

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

Note that the port number should be there without the square brackets: []

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

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