I'm trying to set up a one command way to move website code from a dev machine up into my Ubuntu EC2 instance and have it be copied straight into the /var/www/mywebsite folder where nginx expects to find web sites on that box.
These Ubuntu AMIs come with a default ubuntu user. I can rsync a folder without any trouble from the dev machine to the EC2 instance's /home/ubuntu/ folder:
rsync -avL --progress -e "ssh -i /home/me/myhosts.pem" source-folder email@example.com:~/code
but when I try to rsync that same folder to /var/www as root:
rsync -avL --progress -e "ssh -i /home/me/myhosts.pem" source-folder firstname.lastname@example.org:/var/www/
I get the following error:
protocol version mismatch -- is your shell clean? (see the rsync man page for an explanation) rsync error: protocol incompatibility (code 2) at compat.c(174) [sender=3.0.9]
I'm not exactly clear on why this is happening. I noticed that I've not been able to ssh in as root as I get the following message:
Please login as the user "ubuntu" rather than the user "root". Connection to ec2[...] closed.
which might explain the behavior above. sshd_config does have "PermitRootLogin" yes though, but I guess that's blocked somewhere else.
I guess one option would be to alter the permissions of the /var/www folder (right now it's 755 root root) and allow ubuntu to copy files there without having to elevate to root every time. I'm however not sure if that's a good idea security-wise and if that's the right solution here, so I'd appreciate advice.