When cloning a Git repository that contains submodules from another server using SSH, I encounter an error:
Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
The repository is hosted on Server A, but it includes submodules cloned from Server B.
To overcome the host key verification failure when cloning a Git repository with submodules using SSH, you can override the installer’s known_hosts file by creating a custom Docker image.
Here are the steps to follow:
Create a new directory and navigate into it.
Create a Dockerfile in this directory with the following content:
FROM okteto/pipeline-runner:1.0.4
COPY --chmod=0600 known_hosts /root/.ssh/known_hosts
Run the command below to generate and save the SSH host keys for your repository to a file named known_hosts:
By following these steps, you should be able to resolve the host key verification issue and successfully clone your Git repository with submodules using SSH.