Answer the question
In order to leave comments, you need to log in
How to connect from gitlab ci to a remote server?
I repeat the example from the documentation here https://docs.gitlab.com/ee/ci/ssh_keys/README.html...
on a remote server copied id_rsa into the SSH_PRIVATE_KEY variable on gitlab
my .gitlab-ci.yml
stages:
- build
build stage:
image: node:10.15.0-stretch
stage: build
only:
- master
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 ****@**** ls
....
$ command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )
$ eval $(ssh-agent -s)
Agent pid 11
$ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
Identity added: (stdin) ((stdin))
$ mkdir -p ~/.ssh
$ chmod 700 ~/.ssh
$ ssh ****@**** ls
Host key verification failed.
ERROR: Job failed: exit code 1
Answer the question
In order to leave comments, you need to log in
The message "Host key verification failed." says that it doesn’t get to check the user’s key (SSH_PRIVATE_KEY), because everything slows down to check the server’s fingerprint (SSH_KNOWN_HOSTS)
In the same article it says what to do with this:
https://docs.gitlab.com /ee/ci/ssh_keys/README.html...
Another option is to ignore the host fingerprint:
ssh -o StrictHostKeyChecking=no ****@**** ls
But this is not secure - you can get to MITM.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question