I am creating an ec2 instance from an AMI using
aws ec2 run-instances [lots of arguments] --user-data file://my_sh_file.sh
my_sh_file.sh looks like this:
su ubuntu # fails with or without this
cd /home/ubuntu/my_working_dir
git pull origin master
. app_startup_script.sh
Git is failing to connect with this error log (from /var/log/cloud-init-output.log):
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If I log in myself (as ubuntu) and call git pull it works fine.
I guess that either (a) su ubuntu isn't working, or (b) (this seems less likely) that the ssh config isn't loaded at this point in the boot sequence... but I'm stumped. Help?
git remote -v
please. By the way, do you use ssh-agent?