diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-10-13 10:53:19 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-10-13 10:53:19 +0100 |
commit | 0381cd72d6d390c52e7a7b2963c762f4a8e3c540 (patch) | |
tree | dac2f86a0e4d95d7a94cd793a231edf496d1db77 | |
parent | 225002076de1643a00a4a2763c08704ceb03e993 (diff) | |
download | obnam-0381cd72d6d390c52e7a7b2963c762f4a8e3c540.tar.gz |
Add ssh-command setting
Patch by Lars Kruse.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | obnamlib/plugins/sftp_plugin.py | 15 | ||||
-rwxr-xr-x | test-sftpfs | 2 |
3 files changed, 18 insertions, 2 deletions
@@ -25,6 +25,9 @@ Version 1.6, released UNRELEASED obey a new option, `--key-details`, to show the usernames attached to each public key. Patch by Lars Kruse. +* New option `--ssh-command` to set the command Obnam runs + when invoking ssh. patch by Lars Kruse. + Bug fixes: * Fix "obnam list-toplevels" so it doesn't give an error when it's diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py index b0b6e08b..f185b05e 100644 --- a/obnamlib/plugins/sftp_plugin.py +++ b/obnamlib/plugins/sftp_plugin.py @@ -152,10 +152,12 @@ class SftpFS(obnamlib.VirtualFileSystem): self.chdir(self.path) def _connect_openssh(self): - args = ['ssh', - '-oForwardX11=no', '-oForwardAgent=no', + executable = 'ssh' + args = ['-oForwardX11=no', '-oForwardAgent=no', '-oClearAllForwardings=yes', '-oProtocol=2', '-s'] + if self.settings and self.settings['ssh-command']: + executable = self.settings["ssh-command"] # default user/port from ssh (could be a per host configuration) if self.port: args += ['-p', str(self.port)] @@ -171,6 +173,8 @@ class SftpFS(obnamlib.VirtualFileSystem): self.settings['ssh-known-hosts']] args += [self.host, 'sftp'] + # prepend the executable to the argument list + args.insert(0, executable) logging.debug('executing openssh: %s' % args) try: proc = subprocess.Popen(args, @@ -623,6 +627,13 @@ class SftpPlugin(obnamlib.ObnamPlugin): os.path.expanduser('~/.ssh/known_hosts'), group=ssh_group) + self.app.settings.string(['ssh-command'], + 'alternative executable to be used instead ' + 'of "ssh" (full path is allowed, no ' + 'arguments may be added)', + metavar='EXECUTABLE', + group=ssh_group) + self.app.settings.boolean(['pure-paramiko'], 'do not use openssh even if available, ' 'use paramiko only instead', diff --git a/test-sftpfs b/test-sftpfs index 52f7e369..6a7b9b93 100755 --- a/test-sftpfs +++ b/test-sftpfs @@ -49,6 +49,7 @@ class SftpTests(unittest.TestCase, obnamlib.VfsTests): 'ssh-key': '', 'strict-ssh-host-keys': False, 'ssh-known-hosts': os.path.expanduser('~/.ssh/known_hosts'), + 'ssh-command': None, } self.fs = obnamlib.plugins.sftp_plugin.SftpFS(baseurl, settings=settings) @@ -70,6 +71,7 @@ class SftpTests(unittest.TestCase, obnamlib.VfsTests): 'ssh-key': '', 'strict-ssh-host-keys': False, 'ssh-known-hosts': os.path.expanduser('~/.ssh/known_hosts'), + 'ssh-command': None, } fs = obnamlib.plugins.sftp_plugin.SftpFS(baseurl, settings=settings) fs.connect() |