I want to synchronize a directory /var/sites/example.net/from a remote computer to a directory in the same path on my local computer.
The remote computer only authenticates SSH connections with keys, not passwords.
On my local machine, I have an alias set to ~ / .ssh / config, so that I can easily run ssh myserverto login.
I try rsync -a myserver:/var/sites/example.net/ /var/sites/example.net/, but it fails because my local user does not have permission to edit the local directory /var/sites/example.net/.
If I try sudo rsync -a myserver:/var/sites/example.net/ /var/sites/example.net/(just adding sudo), I can fix the local resolution problem, but then I came across another problem - my local root user does not see the correct ssh key or ssh alias.
Is there a way to perform this file synchronization by changing this rsync command? I would like to avoid changing anything else (e.g. no changes in perms or ssh settings)
source
share