jim-easterbrook / pywws

Python software for USB Wireless WeatherStations
https://pywws.readthedocs.io/
GNU General Public License v2.0
204 stars 62 forks source link

Added option for SFTP-authentication with public key #53

Closed peletiah closed 6 years ago

peletiah commented 6 years ago

I'm using this for passwordless authentication to my SSH-server, with private and public SSH-keys.

I was not sure how best to handle setting a default password (Used to be set to "secret" if the parameter was missing in weather.ini). I've removed this for now as it seems counterintuitive if you set a privkey-parameter and then automatically get a password = secret added in your weather.ini. This can however easily be replaced with the old behaviour without causing any errors (As _sftp.connect() first tries the privkey).

I've tested my change with several scenarios - without parameters, with one parameter each, with a broken ssh-key and with a encrypted ssh-key - there are proper and relevant error-messages for error cases and if only one parameter is given it works fine. A proper error-message is also the reason for replacing the paramiko.Transport.connect()-method with the separate methods to initialize the transport, as only these appear to provide relevant exceptions and error-messages.

I've also updated the docs, but I was again not sure if I should add the privkey-parameter in the example-ini - I've left it out, as one can assume a user that uses public key authentication knows what they are doing.

jim-easterbrook commented 6 years ago

That looks OK to me. You forgot to add your name to name to the contributors list though. (See http://pywws.readthedocs.io/en/latest/copyright.html#contributing-to-pywws) If you do this before I merge the pull request it should get incorporated into the pull request.

peletiah commented 6 years ago

Just realized that, you where faster :-)