Sending files, and directories remotely can be achieved with a lot of utility tools. One of them is Rsync, which is a cool tool for remote transfer. Let’s see how to install it on Amazon Linux 2 and use some basic commands.
Prerequisites
- Amazon Linux 2
- sudo privileges
Install Rsync on Amazon Linux 2
Step 1. Update the default Amazon Linux 2 packages.
sudo yum update
Step 2. Install Rsync.
sudo yum install rsync
Step 3. Transfer data from a local to a remote machine.
rsync -a /home/site/file.zip username@domain_or_ip:/home/devcoops/
If you need to provide an SSH key, run:
rsync -a -e "ssh -i /path/to/key.pem" /home/site/file.zip username@domain_or_ip:/home/devcoops/
Step 4. Transfer data from a remote to a local machine.
rsync -a username@domain_or_ip:/home/devcoops/file.zip /home/site/
If you need to provide an SSH key, run:
rsync -a -e "ssh -i /path/to/key.pem" username@domain_or_ip:/home/devcoops/file.zip /home/site/
Conclusion
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.