
最近一个星期都在用centos架设docker+gitlab+jenkins,一个多星期了,啊~~~崩溃。。。。尤其遇到这个问题,真的折磨了我好久好久。
那就是生成密匙id_rsa的时候,如果默认放/root/.ssh/id_rsa里面时候,可以正常拉取仓库。
git clone ssh://git@192.168.200.129:13822/root/test-demo1.git
如果我改变文件夹,如密匙放/usr/local/gitlab/.ssh/id_rsa里面的时候,就会报下列错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
期初以为是文件夹权限问题,试了以下口令,均没用:
没用1:chown -R 1000:1000 /usr/local/gitlab/.ssh
没用2:sudo chmod +x /usr/local/gitlab/.ssh/id_rsa.pub
sudo chmod +x /usr/local/gitlab/.ssh/id_rsa
后来,百度,好不容易找到了方法。
解决办法:
a.终端输入
ssh-agent -s
出现类似
SSH_AUTH_SOCK=/tmp/ssh-3jVEHO6R8Y6E/agent.91696; export SSH_AUTH_SOCK;
SSH_AGENT_PID=91697; export SSH_AGENT_PID;
echo Agent pid 91697;
b.终端继续输入
ssh-add /usr/local/gitlab/.ssh/id_rsa
如果出现下边字符,则成功
Identity added: /usr/local/gitlab/.ssh/id_rsa (/usr/local/gitlab/.ssh/id_rsa)
如果出现下列错误
Could not open a connection to your authentication agent.
则,执行
eval `ssh-agent -s`
然后再重新输入口令:
Identity added: /usr/local/gitlab/.ssh/id_rsa (/usr/local/gitlab/.ssh/id_rsa)
c.拉取测试
git clone ssh://git@192.168.200.129:13822/root/test-demo1.git
出现了下边字符则表明成功:
Cloning into 'test-demo1'...
warning: You appear to have cloned an empty repository.
可以看看docker+gitlab+jenkins持续集成配置哦。
admin:docker下jenkins与gitlab构建ci持续集成,踩了各种坑。zhuanlan.zhihu.com