歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

SSH默認端口更改後使用Git

由於安全或者其它原因,我們可能會修改默認的SSH服務端口號,默認情況下,已有的git項目在pull或者push的時候會報錯。

現在假設原來的項目的remote設置為git@linuxidc.com:Projects/p1.git,將服務器SSH默認端口修改為3022後,導致push出錯。

有兩個解決辦法:

一、直接修改URL為SSH://開頭
git remote set-url origin ssh://git@linuxidc.com:3022/~/Projects/p1.git

二、 修改本地配置文件
cat>~/.ssh/config
# 映射一個別名
host newlinuxidc
hostname linuxidc.com
port 3022
# ctrl+D

修改p1.git項目下的git配置文件
git remote set-url origin git@newlinuxidc:Projects/p1.git

GitHub 教程系列文章: 

Ubuntu12.04 Git 服務器配置圖文詳解  http://www.linuxidc.com/Linux/2015-05/117502.htm

GitHub 使用教程圖文詳解  http://www.linuxidc.com/Linux/2014-09/106230.htm 

Git 標簽管理詳解 http://www.linuxidc.com/Linux/2014-09/106231.htm 

Git 分支管理詳解 http://www.linuxidc.com/Linux/2014-09/106232.htm 

Git 遠程倉庫詳解 http://www.linuxidc.com/Linux/2014-09/106233.htm 

Git 本地倉庫(Repository)詳解 http://www.linuxidc.com/Linux/2014-09/106234.htm 

Git 服務器搭建與客戶端安裝  http://www.linuxidc.com/Linux/2014-05/101830.htm 

Git 概述 http://www.linuxidc.com/Linux/2014-05/101829.htm 

分享實用的GitHub 使用教程 http://www.linuxidc.com/Linux/2014-04/100556.htm 

Git 的詳細介紹:請點這裡
Git 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved