How do I automate population of known_hosts and authorized_keys?
You have to execute ssh-keyscan. For example to ssh to a host (github.com here ) you have to run below script 

# Add ssh key to help cloning private github repo

ssh-keygen -t rsa -N "" -f secrets/ssh/github_rsa
PUB_KEY=$(cat secrets/ssh/github_rsa.pub)
PRV_KEY=$(cat secrets/ssh/github_rsa)

echo "${PRV_KEY}" &gt;&gt; ~/.ssh/github_rsa
chmod 600 ~/.ssh/github_rsa
eval $(ssh-agent)
ssh-add ~/.ssh/github_rsa

ssh-keyscan github.com &gt;&gt; ~/.ssh/known_hosts
echo IdentityFile ~/.ssh/github_rsa &gt;&gt; ~/.ssh/config

echo "Paste the following public key to your host machine ".${PUB_KEY}