I'm working with two ubuntu instances on AWS (which I use a pem key to access them).I set up rsync for both instances, and it works if I use the default user which is ubuntu@ipaddress. However if I try to use rsync with another user (I'm typing sudo su - jenkins for example or even typing sudo before the rsync command), then I get the following error.Permission denied (publickey).rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.0]Steps that I've taken:I've tried creating an ssh key (using ssh-keygen) while logged in as jenkins and added that to the authorized_keys file in both /home/ubuntu/.ssh/authorized_keys (where i'm running the rsync from) and even $JENKINS_HOME/.ssh/authorized_keys (where I tried running rsync from there too).I even tried using the pem key to do the same thing and that didn't work either.Here's what I'm trying to runrsync -avuh --delete -e ssh jenkins@ipaddress:/var/lib/jenkins/* /var/lib/jenkinsAnd here's with the key filersync -avuh --delete -e 'ssh -i path/to/key.pem' jenkins@10.96.2.210:/var/lib/jenkins/* /var/lib/jenkinsP.S.: The only reason why I don't want to run it with the ubuntu user is because I get failed: Permission denied (13) on a lot of things (since the files are owned by jenkins).End goal:I'm trying to keep the backup jenkins instance backed up constantly with the primary instance by doing a cronjob:*/30 * * * * /usr/bin/rsync -avuh --delete -e ssh root@jenkinsprimary:/var/lib/jenkins/* /var/lib/jenkins
rsync with different user
ubuntu;ssh;rsync;aws