0

I am trying to connect to a docker daemon running on a VM using DOCKER_HOST="ssh://user@IPAddress". I have configured the machine using with correct ssh keys.

From the gitlab-runner VM I can manually login to the remote machine using ssh user@IPAddress. I accessing it under the gitlab-runner user account. gitlab-runner account is in the docker group. It is a non login account. Not added to the sudo group either. When I try to accesss docker daemon from a gitlab CI job with Shell executor.

Job:
  - echo "$(whoami)"
  - eval $(ssh-agent -s)
  - ssh-add ~/.ssh/id_rsa_devops
  - export DOCKER_HOST="ssh://user@IPAddress"
  - docker info

Output

gitlab-runner
Agent pid 7418
/home/gitlab-runner/.ssh/id_rsa_devops: No such file or directory

I checked the key, and it is there on that path. I am not sure what is going wrong can someone tell me please ?

2
  • What is the file permission based on the output of stat ~/.ssh/id_rsa_devops ? Commented Jun 6, 2020 at 15:11
  • @Lukman Access: (0600/-rw-------) Uid: ( 999/gitlab-runner) Gid: ( 998/gitlab-runner) Commented Jun 7, 2020 at 9:31

2 Answers 2

1

I fixed it with the extra line after the ssh-add instruction and it worked.

- ssh-keyscan <IPAddress here> >> ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts

Sign up to request clarification or add additional context in comments.

Comments

0

Recently, I have implemented similar scenario (datacenter). There I created a gitlab-runner login account and once you have to log to remote server from it to make authenticity.

1 Comment

I have already done it. I wrote that I can login from the gitlab-runner machine to the remote machine using the key and account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.