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:
@@ -559,9 +559,7 @@ class Backup:
|
|||||||
rsync = f'/usr/bin/rsync {self.options} --link-dest="{self._last_backup}" --exclude-from=' +\
|
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}"'
|
f'{self._exclude_path} --files-from={self._inputs_path} / "{self._server}{self._output_dir}"'
|
||||||
|
|
||||||
euid = os.geteuid()
|
if self.ssh_keyfile is not None:
|
||||||
|
|
||||||
if euid == 0 and self.ssh_keyfile is not None:
|
|
||||||
rsync = f'{rsync} -e \'ssh -i {self.ssh_keyfile} -o StrictHostKeyChecking=no\''
|
rsync = f'{rsync} -e \'ssh -i {self.ssh_keyfile} -o StrictHostKeyChecking=no\''
|
||||||
elif self._password_auth and which('sshpass'):
|
elif self._password_auth and which('sshpass'):
|
||||||
rsync = f'{rsync} -e \'sshpass -e ssh -l {self.ssh_user} -o StrictHostKeyChecking=no\''
|
rsync = f'{rsync} -e \'sshpass -e ssh -l {self.ssh_user} -o StrictHostKeyChecking=no\''
|
||||||
|
|||||||
Reference in New Issue
Block a user