How to Ignore SSH Host Key Verification

While running a script to login to multiple remote servers using sshpass (or) keybased authentication (or) while logging to remote server using ssh (or) while copying the file using SCP.

There are chances we might have encountered this "Host Key Verification failed" message.

All the time we cannot do manual ssh and click yes to add the host key into ~/ssh/known_hosts file.

Here is some alternative trick that helps.

Just use these flags in scp and ssh to get rid of this messages.

SSH

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no  [email protected]

SCP

scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no somefile.txt [email protected]:/var/tmp/

Hope this helps!

Cheers

A K S A R A V