We have files in our locahost and want to upload it into our ec2 amazon server using commandline. We know that AWS just support SSH as default main communication between client and server. FTP is difficult to be installed also SFTP will makes uploading time so long. Why don't use rsync as default command in Linux? We can synchronize files in our computer into ec2 server easily. Here are commandline for rsync between client and ec2 server :
In this example, we in directory where our .pem key located for easy managing. You want to syncronize content in YOURLOCAHOSTFOLDER into /var/www in your ec2 amazon server.
EC2 instance example is ubuntu@ec2-IP-ADDRESS.compute.amazonaws.com.
sudo rsync -avr /YOURLOCAHOSTFOLDER/* -e "ssh -i YOURKEYPEM.pem" ubuntu@ec2-IP-ADDRESS.compute.amazonaws.com:/var/www/
You can create this command as rsync.sh and execute by sudo sh rsync.sh.