I'm setting up a crontab server to run several jobs to copy files from prod servers to lower environment servers.

I need the cron server job to copy files from one server to another. Here is what I have.

the ip's have been modified

ssh -v -R localhost:50000: -i host1key.pem ec2-user@ 'rsync -e "ssh -i /home/ec2-user/host2key.pem -p 50000" -vuar /home/ec2-user/test.txt ec2-user@localhost:/home/ec2-user/test.txt'

I'm using two different pem keys and users. I would think this command would work but I get this error in the debug log. Here is more to it and only show the portion that is erroring. It connects to ec2-user@ successfully. But errors on the

debug1: connect_next: host ([]:22) in progress, fd=7
debug1: channel 1: new []
debug1: confirm forwarded-tcpip
debug1: channel 1: connected to port 22
Host key verification failed.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]
debug1: channel 0: free: client-session, nchannels 2
debug1: channel 1: free:, nchannels 1
Transferred: sent 5296, received 4736 bytes, in 0.9 seconds
Bytes per second: sent 5901.2, received 5277.2
debug1: Exit status 12
  • Are the two hosts in the same VPC? In the same security group? In the same IP subnet? – DopeGhoti Jul 5 '17 at 23:10
  • @DopeGhoti - No, no and no. The prod server ( is in one AWS account and, the lower sever ( in another. Also, the cron server is in the same vpc, sg, sub as the product server. – chdev77 Jul 6 '17 at 2:59

I have exactly the same issue.
In order for RSYNC to do what you want, server and must have a connection between them. This may not seem obvious, however it is, in fact, true.

Reading a little bit between the lines, I'm going to stick my neck out and that there is no direct connection between .1 and .2 and there is no way to get one.

In that scenario, I have always pulled the data from .1 and then pushed it to .2. That makes it 2 processes and takes twice as long.

Hopefully, this answer will help other folks in the same situation.
I spent months trying to figure it out. Maybe this will save some of you a lot of time.

| improve this answer | |

The error message shows the problem

Host key verification failed.

Your key is either incorrect or you have not yet confirmed (interactively) that it is correct.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.