ssh-keyscan throws write :Operation times out

2/4/2019

I have gitlab runner installed on kubernetes. I am trying to build docker image from a Dockerfile which needs to clone private repositories over ssh. I have added ssh-keyscan to get public key of the repo URL.
It throws following error most of the times :

write (git..com): Operation timed out

I have tried increasing timeout but the behaviour is still the same.

This is the command I am running from Dockerfile

RUN mkdir -p -m 0600 /root/.ssh && ssh-keyscan  -vvv -T 300 -p  <port> git.<kygitlab>.com >> /root/.ssh/known_hosts

The public key should be stored into know_hosts file without any error. This works fine in my local system but throws an error when executed with gitlab CI on kubernetes.

-- Parath
gitlab
kubernetes
ssh

1 Answer

2/5/2019

The problem is:

  • you don't need to update only the known_hosts,
  • you also need a private/public key pair (in the ~/.ssh Docker image folder), with the public key registered on the remote private repo hosting service side.

Only that would allow you to access and clone a private remote repo.

-- VonC
Source: StackOverflow