ssh: connect to git@gitlab.xxxxx.com:xxxxx.git port 22: Connection refused

公司服务器上的gitlab项目添加了ssh密钥,但是操作时却报错ssh: connect to git@gitlab.xxxxx.com:xxxxx.git port 22: Connection refused

经过研究发现gitlab不仅支持ssh也支持http链接获取项目:

将原来的ssh链接git@gitlab.xxxxx.com:xxxxx.git改成https的链接https://gitlab.xxxxxxxxx.com/xxxxxxxxx.git就行了

比如git clone https://gitlab.xxxxxxxxx.com/xxxxxxxxx.git 会提示你输入账号密码,这个账号密码就是登陆你们公司gitlab服务器时用的账号密码

如果之前本地有项目了则执行下面代码

查看本地项目对应的远程链接:git remote -v

将git@gitlab.xxxxx.com:xxxxx.git改成https的链接https://gitlab.xxxxxxxxx.com/xxxxxxxxx.git:

git remote set-url origin https://gitlab.xxxxxxxxx.com/xxxxxxxxx.git

然后就能正常push pull fetch了

原文地址:https://www.cnblogs.com/agilezhu/p/7039752.html