解决runner Host key verification failed. lost connection
ssh-keygen -t rsa -b 2048 -C "email@example.com"
scp -r id_rsa.pub root@1.2.3.4:/root/.ssh/authorized_keys
配置免密 登录的步骤
gitlab-runner 是使用docker方式启动的
遇到这个问题,不要慌,不要急,狠狠地看几遍官方的文档.
https://docs.gitlab.com/ee/ci/ssh_keys/README.html
然后在你的运行runner的机器上,记住不是在容器里,删除 ~/.ssh/known_hosts
登录 ssh root@123.12.12.12 这时会询问你 是要保存指纹, 选yes
类似这样的
另外在job 的 before_script 节点的内容如下
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan 115.159.52.223 >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
官方的例子
https://gitlab.com/gitlab-examples/ssh-private-key/-/blob/master/.gitlab-ci.yml
还没有评论,来说两句吧...