diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-12-29 20:17:47 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-12-29 20:17:47 +0000 |
commit | 38d42cff2976923f8f7c7e2a643b732cf0acd580 (patch) | |
tree | 873342d5e5751368063c8c788d1b6593fd4843ce | |
parent | 557e6b0c95d04d2e405b2e44ae3cbfdfa0d51697 (diff) | |
download | obnam-38d42cff2976923f8f7c7e2a643b732cf0acd580.tar.gz |
implement strict-ssh-host-keys and ssh-known-hosts settings for openssh
-rw-r--r-- | obnamlib/plugins/sftp_plugin.py | 7 | ||||
-rwxr-xr-x | test-sftpfs | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py index 7510bdf0..00342f53 100644 --- a/obnamlib/plugins/sftp_plugin.py +++ b/obnamlib/plugins/sftp_plugin.py @@ -143,8 +143,15 @@ class SftpFS(obnamlib.VirtualFileSystem): '-s'] if self.settings and self.settings['ssh-key']: args += ['-i', self.settings['ssh-key']] + if self.settings and self.settings['strict-ssh-host-keys']: + args += ['-o', 'StrictHostKeyChecking=yes'] + if self.settings and self.settings['ssh-known-hosts']: + args += ['-o', + 'UserKnownHostsFile=%s' % + self.settings['ssh-known-hosts']] args += [self.host, 'sftp'] + logging.debug('executing openssh: %s' % args) try: proc = subprocess.Popen(args, stdin=subprocess.PIPE, diff --git a/test-sftpfs b/test-sftpfs index 06694228..b73ce571 100755 --- a/test-sftpfs +++ b/test-sftpfs @@ -42,12 +42,12 @@ class SftpTests(unittest.TestCase, obnamlib.VfsTests): self.basepath = tempfile.mkdtemp() baseurl = 'sftp://localhost%s' % self.basepath settings = { - 'pure-paramiko': True, + 'pure-paramiko': False, 'create': True, 'sftp-delay': 0, 'ssh-key': '', 'strict-ssh-host-keys': False, - 'ssh-known-hosts': '/dev/null', + 'ssh-known-hosts': os.path.expanduser('~/.ssh/known_hosts'), } self.fs = obnamlib.plugins.sftp_plugin.SftpFS(baseurl, settings=settings) |