rsync over SSH with Key

Assume you have a remote machine which allows SSH login with key generated in [1]. The user account is foo and the key is stored in the file ~/fookey. The IP of the remote machine is

You want to copy the content of local ~/local_dir/ to remote ~/remote_dir of user foo via the following rsync command:

$ rsync -avz ~/local_dir/ foo@ -e 'ssh -i ~/fookey'


[1][AWS] Create/Migrate Linux Users on Amazon EC2
[4]rsync over ftp - Google search