Let using sudo only for backup
When we want to do a backup for all user of a machine, we use sudo. But this way, the entire program is run with sudo. It will be better to only run rsync with sudo.
Or even better, ask for user password to perform the backup under their name.
But we have to pay attention, that generally, only the user that is launching the command can log into the server with ssh. For now, using sudo, it's the root user that have access to the save server.
So when saving for multiple home users, we want:
- only the current user can connect to the ssh server (see: identity flag for ssh, referencing ssh key in config file).
- prevent command to run by root user (but maybe running rsync under root is save, because we use it also for saving file from system, where we have to be root).
- ask for password only once at the beginning (maybe the user has configured visudo to allow the user to run rsync in sudo without password, how to check that ?).