Git: git clone – fatal: unable to fork and RSA key fingerprint

By | 10/23/2020

We have a Docker image with Git client installed.

The task is to automatically clone a repository when running a container from this image.

git clone – fatal: unable to fork

When running the git clone command in a container from this Docker image it fails with the “unable to fork” error:

/ # git clone
Cloning into 'backend-services'...
fatal: unable to fork

The cause is that git uses SSH for authentication here (, but we have no ssh client installed in the image:

/ # ssh
sh: ssh: not found

Install it:

/ # apk update
/ # apk add openssh

The authenticity of host ‘’ can’t be established

Another issue when automating git clone – it’s asking to confirm the RSA key from the host:

The authenticity of host ‘ (’ can’t be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?

To solve this – need to add its public key to the ~/.ssh/known_hosts file.

Use ssh-keyscan for this:

/ # ssh-keyscan >> ~/.ssh/known_hosts SSH-2.0-babeld-1a846ed2 SSH-2.0-babeld-1a846ed2 SSH-2.0-babeld-1a846ed2

And now clone the repository:

/ # git clone
remote: Total 5115 (delta 96), reused 169 (delta 56), pack-reused 4871
Receiving objects: 100% (5115/5115), 846.55 KiB | 3.00 MiB/s, done.
Resolving deltas: 100% (2826/2826), done.