1
votes

I'm trying to automate a deploy using ansible, and it gets stuck during git clone. That happens in the usual message

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

How can I use known_module (or other module) to add the host and prevent this message from getting the playbook stuck?

The git repository is only available on a different port, not the usual 22 port for SSH. This shell command works in the host terminal, but not in ansible playbook. It gets lost in the quotes and backslahes.

- name: manual add remote to known_hosts
  shell: "ssh-keyscan -H -p 7999 my.host | sed -e 's/\[//g' | sed -e 's/\]\:7999//g' >> /home/vm_user/.ssh/known_hosts"

Any suggestions on what should I do?

1

1 Answers

-1
votes

You can avoid this prompt by setting stricthostkeychecking no in your .ssh/config file. This may be a security risk, as you will only be warned if some host key changed, but ssh still connects (and may transmit sensitive data to an attacker).