1. 程式人生 > >Git配置非22端口,解決:ssh: connect to host xxx port 22: Connection timed out fatal: The remote end hung up unexpectedly

Git配置非22端口,解決:ssh: connect to host xxx port 22: Connection timed out fatal: The remote end hung up unexpectedly

name 訪問 基於 .net article 自定義 一個 實現 背景

背景:私自搭建了Git服務器,而Git本身就是SSH進行連接的,而Git命令上默認只能通過22端口實現。

解決方法:

第一種:

在系統的用戶目錄下的文件夾:.ssh

如果該路徑下沒有config文件,則創建一個。

config中添加如下內容:

如是以域名訪問的則添加如下內容:(註意修改xxx為你的遠程倉庫的名稱)

Host xxx
HostName xxx.com
Port 3333

如是以IP訪問的,則添加如下內容:(註意修改IP為你的遠程倉庫IP)

Host "211.111.xx.xxx"
Port 3333

第二種:

Git本身基於SSH的,所以直接使用SSH的寫法來增加自定義端口號

git clone ssh://[email protected]:3022/~/Projects/p1.git

參考:

http://blog.csdn.net/u010041075/article/details/52981731

http://blog.csdn.net/daiwood/article/details/50561306

Git配置非22端口,解決:ssh: connect to host xxx port 22: Connection timed out fatal: The remote end hung up unexpectedly