I’m trying to launch an EC2 instance with a script in the user-data. The script contains an rsync call to a remote server but this fails. I believe this is because I need to setup the user that runs the user-data to be able to connect to the remote server.
What user runs the user-data script?
The stderr that I have logged is:
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(601) [Receiver=3.0.7]
It appears the script is run as
root. So if you have to communicate via SSH, make sure that the root account is able to make the connections.