1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-23 08:16:54 +00:00

add support for arbitrary SSH commands (attic#99)

while SSH options can be specified through `~/.ssh/config`, some users
may want to use a completely different SSH command for their backups,
without overriding their $PATH variable. it may also be easier to do
ad-hoc configuration and tests that way.

plus, the POLA tells us that users expects something like this to be
supported by commands that talk to ssh. it is supported by rsync, git
and so on.
This commit is contained in:
Antoine Beaupré 2015-10-05 18:54:00 -04:00
parent 43a65933f7
commit a0ef4e25dd
3 changed files with 6 additions and 1 deletions

View file

@ -3,6 +3,7 @@
import msgpack
import os
import select
import shlex
from subprocess import Popen, PIPE
import sys
import tempfile
@ -160,7 +161,7 @@ def umask_flag(self):
return ['--umask', '%03o' % self.umask]
def ssh_cmd(self, location):
args = ['ssh']
args = shlex.split(os.environ.get('BORG_RSH', 'ssh'))
if location.port:
args += ['-p', str(location.port)]
if location.user:

View file

@ -328,6 +328,8 @@ def test_invalid_rpc(self):
def test_ssh_cmd(self):
assert self.repository.umask is not None
assert self.repository.ssh_cmd(Location('example.com:foo')) == ['ssh', 'example.com', 'borg', 'serve'] + self.repository.umask_flag()
os.environ['BORG_RSH'] = 'ssh --foo'
assert self.repository.ssh_cmd(Location('example.com:foo')) == ['ssh', '--foo', 'example.com', 'borg', 'serve'] + self.repository.umask_flag()
class RemoteRepositoryCheckTestCase(RepositoryCheckTestCase):

View file

@ -48,6 +48,8 @@ General:
can either leave it away or abbreviate as `::`, if a positional parameter is required.
BORG_PASSPHRASE
When set, use the value to answer the passphrase question for encrypted repositories.
BORG_RSH
When set, use this command instead of ``ssh``.
TMPDIR
where temporary files are stored (might need a lot of temporary space for some operations)