Answer yes in a bash script
Add the following to your ~/.ssh/config
file:
Host github.com
StrictHostKeyChecking no
Anything using the open-ssh client to establish a remote shell (with the git client does) should skip the key checks to github.com.
This is actually a bad idea since any form of skipping the checks (whether you automatically hit yes or skip the check in the first place) creates room for a man in the middle security compromise. A better way would be to retrieve and validate the fingerprint and store it in the known_hosts
file before needing to run some script that automatically connects.
yes
outputs y
. RSA key acceptance needs yes
. You could try yes yes | git clone [email protected]:repo/repoo.git
so yes
outputs yes
instead of y
.
Running ssh-keyscan -H github.com >> ~/.ssh/known_hosts
before cloning will add the key and prevent the prompt from appearing.
Of course this approach is also vulnerable to a MITM attack.