Sshpass to connect to a remote host from CI build farm pod

You could have a requirement to use the sshpass utility to copy the files from the CI build farm pod to a remote host machine.

If we directly use the below command in CI run step to scp the files from build farm pod to any other host it would fail with an error Host key verification failed.

sshpass -p <password> scp <file> user@x.x.x.x.x:/home

In order to get this working, you would need to add the ssh key of the remote host to the known_hosts file in the CI step container.

You can add the below command in the CI run step. Replace the server-ip with the remote host IP/name against which you need to run sshpass.

ssh-keyscan server-ip >> ~/.ssh/known_hosts

Note that you need to either install or use an image with the ssh utilities to be able to run the above command in the step container.