diff options
author | Lars Wirzenius <liw@iki.fi> | 2008-05-16 22:37:14 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@iki.fi> | 2008-05-16 22:37:14 +0300 |
commit | fa8f864c610707128e78b13b84ca5e8b353894fc (patch) | |
tree | 25a48d599d276e5520bfb0ce53f77fe8d4c67eec /obnam | |
parent | f8540391b1b80273099c8208a37695d820398684 (diff) | |
download | obnam-fa8f864c610707128e78b13b84ca5e8b353894fc.tar.gz |
Load both DSA and RSA type SSH keys.
Diffstat (limited to 'obnam')
-rw-r--r-- | obnam/backend.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/obnam/backend.py b/obnam/backend.py index ad274245..73c812ad 100644 --- a/obnam/backend.py +++ b/obnam/backend.py @@ -208,13 +208,20 @@ class Backend: class SftpBackend(Backend): io_size = 64 * 1024 + + def load_key(self, filename): + """Load an SSH private key from a file.""" + try: + return paramiko.DSSKey.from_private_key_file(filename) + except paramiko.SSHException: + return paramiko.RSAKey.from_private_key_file(filename) def connect_sftp(self): """Connect to the server, unless already connected""" if self.sftp_transport is None: ssh_key_file = self.config.get("backup", "ssh-key") logging.debug("Getting private key from %s" % ssh_key_file) - pkey = paramiko.DSSKey.from_private_key_file(ssh_key_file) + pkey = self.load_key(ssh_key_file) logging.debug("Connecting to sftp server: host=%s, port=%d" % (self.host, self.port)) |