I\'m trying to run git clone without ssh checking the repository host\'s key. I can do it from ssh like that:
ssh -o UserKnownHostsFile=/dev/nul
Repository level configuration without impacting the system level settings
Consolidating the already available answers, I am choosing the below steps. This ensures that the configuration changes do not impact at the machine level, but just for the repository being worked on. This is needed in my case as my script needs to be executed on a shared Bamboo agent.
1.Clone the repository taking the GIT_SSH_COMMAND approach.
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone ssh://url
2.Once cloned, navigate into repository directory.
cd repo-dir
3.Set core.sshCommand configuration so that all future calls can be just run with git commands like usual, but internally consuming the provided git options.
git config core.sshCommand 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'