diff options
author | Rob Austein <sra@hactrn.net> | 2012-08-02 17:52:27 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-08-02 17:52:27 +0000 |
commit | aee8dbce461fa5081e4f521db147b4db8632d30c (patch) | |
tree | 80e0607d5f0a8ea79e70e9b977b46647aed41f45 /rcynic | |
parent | 5420f7dd561f0730163866b7ea887f487398688c (diff) |
First hack to hostkeys didn't work. Still need option to protect the
clueless from disabling hostkeys accidently, but Iain has a plane to
catch.
svn path=/trunk/; revision=4619
Diffstat (limited to 'rcynic')
-rw-r--r-- | rcynic/rpki-torrent.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/rcynic/rpki-torrent.py b/rcynic/rpki-torrent.py index cd210b46..6068d642 100644 --- a/rcynic/rpki-torrent.py +++ b/rcynic/rpki-torrent.py @@ -168,9 +168,13 @@ def generator_main(): syslog.syslog("Creating upload connection") ssh = paramiko.Transport((cfg.sftp_host, cfg.sftp_port)) + try: + hostkeys = paramiko.util.load_host_keys(cfg.sftp_hostkey_file)[cfg.sftp_host]["ssh-rsa"] + except ConfigParser.Error: + hostkeys = None ssh.connect( username = cfg.sftp_user, - hostkey = paramiko.util.load_host_keys(cfg.sftp_hostkey_file)[cfg.sftp_host]["ssh-rsa"], + hostkey = hostkeys, pkey = paramiko.RSAKey.from_private_key_file(cfg.sftp_private_key_file)) sftp = SFTPClient.from_transport(ssh) @@ -651,10 +655,7 @@ class MyConfigParser(ConfigParser.RawConfigParser): @property def sftp_hostkey_file(self): - try: - return self.get(self.rpki_torrent_section, "sftp_hostkey_file") - except ConfigParser.Error: - return None + return self.get(self.rpki_torrent_section, "sftp_hostkey_file") @property def sftp_private_key_file(self): |