sftp extension and ED25519 encryption

35 views
Skip to first unread message

WindnFog

unread,
Apr 27, 2020, 12:56:46 PM4/27/20
to weewx-user
I'm trying to get Matthew Wall's sftp extension working with weeex 3.9.2 on my Raspberry Pi 4.0.  It's a patched up to date version of Raspbian, but I get the following error on upload to an sftp server:

Apr 27 13:10:19 rhubarb weewx[12591]: imagegenerator: Generated 13 images for StandardReport in 0.49 seconds
Apr 27 13:10:19 rhubarb weewx[12591]: copygenerator: copied 14 files to /var/www/html/weewx
Apr 27 13:10:19 rhubarb weewx[12591]: reportengine: Caught unrecoverable exception in generator 'user.sftp.SFTPGenerator'
Apr 27 13:10:19 rhubarb weewx[12591]:         ****  not a valid DSA private key file
Apr 27 13:10:19 rhubarb weewx[12591]:         ****  Traceback (most recent call last):
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/share/weewx/weewx/reportengine.py", line 204, in run
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      obj.start()
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/share/weewx/weewx/reportengine.py", line 300, in start
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      self.run()
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/share/weewx/user/sftp.py", line 259, in run
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      n = uploader.run()
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/share/weewx/user/sftp.py", line 103, in run
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      cnopts=cnopts)
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/local/lib/python2.7/dist-packages/pysftp/__init__.py", line 142, in __init__
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      self._set_authentication(password, private_key, private_key_pass)
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/local/lib/python2.7/dist-packages/pysftp/__init__.py", line 171, in _set_authentication
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      private_key_file, private_key_pass)
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/local/lib/python2.7/dist-packages/paramiko/pkey.py", line 206, in from_private_key_file
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      key = cls(filename=filename, password=password)
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/local/lib/python2.7/dist-packages/paramiko/dsskey.py", line 65, in __init__
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      self._from_private_key_file(filename, password)
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/local/lib/python2.7/dist-packages/paramiko/dsskey.py", line 224, in _from_private_key_file
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      data = self._read_private_key_file("DSA", filename, password)
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/local/lib/python2.7/dist-packages/paramiko/pkey.py", line 279, in _read_private_key_file
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      data = self._read_private_key(tag, f, password)
Apr 27 13:10:19 rhubarb weewx[12591]:         ****    File "/usr/local/lib/python2.7/dist-packages/paramiko/pkey.py", line 289, in _read_private_key
Apr 27 13:10:19 rhubarb weewx[12591]:         ****      raise SSHException("not a valid " + tag + " private key file")
Apr 27 13:10:19 rhubarb weewx[12591]:         ****  SSHException: not a valid DSA private key file
Apr 27 13:10:19 rhubarb weewx[12591]:         ****  Generator terminated

I installed the extension as per Matthew's instructions here:

https://github.com/matthewwall/weewx-sftp

My weewx.conf section is as follows:

   [[SFTP]]
       skin = sftp
       user = pdunphy
       private_key = /root/.ssh/id_ed25519
       server = palang.ca
       port = 9999
       path = public_html

The error suggests paramiko might not be handling the key properly.  I am using Ed25519 elliptic curve cryptography that I thought should work.  I'd use regular RSA, but the "guy on the other end" wants Ed25519.  Should this work, or is it limited to RSA/DSA cryptography? 

Or . . . am I missing something else?

Paul VE1DX

WindnFog

unread,
Apr 27, 2020, 1:37:49 PM4/27/20
to weewx-user
Quick follow-up.  I switched to RSA keys and got the same error so I don't think it's the type of encryption.  Probably I have something amiss in the config file . . .

WindnFog

unread,
Apr 27, 2020, 2:09:08 PM4/27/20
to weewx-user
OK, I fixed it.  It was the version of paramiko that was messing things up.  If you are using a Pi with Raspbian 10 (Buster), you can't use the default paramiko you get by default.  You have to upgrade:

pip install --user --upgrade paramiko

The default is 2.6.0 and the above command ups it to 2.7.1, which (combined with 2.7.0), has release notes fixing a lot of things . . .

Paul VE1DX



On Monday, April 27, 2020 at 1:56:46 PM UTC-3, WindnFog wrote:
Reply all
Reply to author
Forward
0 new messages