Browse Source

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.
Antoine Beaupré 9 years ago
parent
commit
a0ef4e25dd
3 changed files with 6 additions and 1 deletions
  1. 2 1
      borg/remote.py
  2. 2 0
      borg/testsuite/repository.py
  3. 2 0
      docs/usage.rst

+ 2 - 1
borg/remote.py

@@ -3,6 +3,7 @@ import fcntl
 import msgpack
 import os
 import select
+import shlex
 from subprocess import Popen, PIPE
 import sys
 import tempfile
@@ -160,7 +161,7 @@ class RemoteRepository:
         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:

+ 2 - 0
borg/testsuite/repository.py

@@ -328,6 +328,8 @@ class RemoteRepositoryTestCase(RepositoryTestCase):
     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):

+ 2 - 0
docs/usage.rst

@@ -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)