git克隆代码报错ssh: connect to host gitlab.test.cn port 22: Connection timed out

#gitlab克隆代码报错

 

root@k8s-node3:/tools# git clone git@gitlab.test.cn:backend/core.git
Cloning into 'core'...
ssh: connect to host gitlab.test.cn port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

 

#先telnet服务器22端口是否通畅,端口通畅服务器端22端口没有问题检查本机防火墙和selinux是否打开,端口不通畅请检查服务器带宽(这边报错是由于阿里云的ecs没有配置安全组对22端口的放行报错)

 

telnet 10.0.3.2

 

 

#做git初始化然后在配置用户名和邮箱
#git初始化
git init
#配置用户名和邮箱
git config --global user.name "pengzhenwei"
git config --global user.email "pengzhenwei@wbiao.cn"

#端口通畅可能是秘钥生成方法不对
ssh-keygen -t rsa -C 'xxxxx@xxxx.cn此为gitlab上面填写资料的邮箱'

#再次克隆代码恢复正常

root@k8s-node3:/tools# git clone git@gitlab.test.cn:backend/core.git
Cloning into 'core'...
remote: Counting objects: 25118, done.
remote: Compressing objects: 100% (6240/6240), done.
remote: Total 25118 (delta 18678), reused 25032 (delta 18615)
Receiving objects: 100% (25118/25118), 13.46 MiB | 1003.00 KiB/s, done.
Resolving deltas: 100% (18678/18678), done.

 

posted @ 2023-01-03 16:57  YYQ-  阅读(2056)  评论(0编辑  收藏  举报