git clone ssh 方式无法使用

问题

git clone [email protected]:test123.git
Cloning into 'test123'...
ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决

开始上网找了好多方式都无法解决。最终求助运维工程师,发现端口更改了非ssh默认的22端口。

ssh -T [email protected]:test123.git -p port
Welcome to GitLab, your user name!

人就是这么懒,怎么才能让不用输入端口号,直接拉取或推代码呢?
方法如下,配置 ~/.ssh/config

# add ssh key to [email protected]
# test command:ssh -T [email protected] -p 64208
Host [email protected]
    User username
    #abnormal port, normal is 22 
    Port 88888
    #id_rsa file path
    #IdentityFile /home/yourname/.ssh/id_rsa

之后再拉取或测试,都是非常顺溜的!

# 已经不在需要端口号
ssh -T [email protected]:test123.git
Welcome to GitLab, your user name!

# 非常好使
git clone git clone [email protected]:test123.git
发布了236 篇原创文章 · 获赞 145 · 访问量 44万+

猜你喜欢

转载自blog.csdn.net/u011944141/article/details/103719294