SSH key not added to known_keys automatically?


I setup a deploy key on Gitlab for our project and add it in our config.yml with the following command

- add_ssh_keys:
        - "xx:xx:xx"

This used to work out of the box, but now for some reason the key is not added to known_hosts automatically. I can see that the IdentityFile is added in .ssh/config, but only after I ssh in to the build machine and run the following cmd the key is added to known_hosts.

ssh -T

The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:xxx.
Are you sure you want to continue connecting (yes/no)? yes

Shouldn’t the add_ssh_keys command do this automatically or do I need to append the key manually to known_hosts or do something like "echo -e "Host\n\tStrictHostKeyChecking no\n" > ~/.ssh/config"?

add_ssh_key does not do this automatically. The first approach you describe would work great. The second approach would also work, but there is a security risk that you need to accept if you disable StrictHostKeyChecking.

We describe our recommended approaches here:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.