Pass the SSH key file to rsync also when not running as root

The key file given with --keyfile was only passed to rsync's ssh
command when running as root, so as a normal user rsync ignored it
and fell back to the default keys or the agent.
This commit is contained in:
Fuxino
2026-10-08 20:17:29 +02:00
parent 7091118663
commit 2a5562d1a9
+1 -3
View File
@@ -559,9 +559,7 @@ class Backup:
rsync = f'/usr/bin/rsync {self.options} --link-dest="{self._last_backup}" --exclude-from=' +\
f'{self._exclude_path} --files-from={self._inputs_path} / "{self._server}{self._output_dir}"'
euid = os.geteuid()
if euid == 0 and self.ssh_keyfile is not None:
if self.ssh_keyfile is not None:
rsync = f'{rsync} -e \'ssh -i {self.ssh_keyfile} -o StrictHostKeyChecking=no\''
elif self._password_auth and which('sshpass'):
rsync = f'{rsync} -e \'sshpass -e ssh -l {self.ssh_user} -o StrictHostKeyChecking=no\''