I have an EC2 instance running and I am able to SSH into it.
However, when I try to rsync, it gives me the error Permission denied (publickey).
The command I'm using is:
rsync -avL --progress -e ssh -i ~/mykeypair.pem ~/Sites/my_site/* [email protected]:/var/www/html/
I also tried
rsync -avz ~/Sites/mysite/* -e "ssh -i ~/.ssh/id_rsa.pub" [email protected]:/var/www/html/
Thanks,
The simplest solution would probably to periodically run rsync to sync the changes on one host to another. There are also bidirectional tools similar to rsync, such as Unison. You could use lsyncd to monitor the filesystem, which starts Unison to then perform a sync.
If you want to copy a file from one location to another within your system, you can do so by typing rsync followed by the source file name and the destination directory. Note: Instead of “/home/tin/file1. txt”, we can also type “file1” as we are currently working in the home directory.
Rsync stands for "Remote Sync." The rsync command lets you transfer and synchronize data between different machines and directories. Using the Secure Shell (SSH) protocol, you can copy your files securely to another location. The rsync tool has many benefits when compared to other methods for copying files.
You also have an empty directory called dir2 . To sync the contents of dir1 to dir2 on the same system, you will run rsync and use the -r flag, which stands for “recursive” and is necessary for directory syncing: rsync -r dir1/ dir2.
I just received that same error. I had been consistently able to ssh with:
ssh -i ~/path/mykeypair.pem \ [email protected]
But when using the longer rsync construction, it seemed to cause errors. I ended up encasing the ssh statement in quotations and using the full path to the key. In your example:
rsync -avL --progress -e "ssh -i /path/to/mykeypair.pem" \ ~/Sites/my_site/* \ [email protected]:/var/www/html/
That seemed to do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With