sshconnection.py is trying to use '~/.ssh/authorized_keys' as a private key
Opened this issue · 1 comments
sshconnection.py contains this bit of fallback code in two different places:
file = self.pub_key_file or os.path.expanduser('~/.ssh/authorized_keys')
if not os.path.isfile(file):
raise Exception('No way to authenticate, need key, password, or file of keys, etc..')
self.debug("Using local keys, no keypath/password provided, trying:" + str(file), verbose=verbose)
ssh._auth(username, password,None,[file], True, True)
This means that it's doing a couple of things wrong:
- it's trying to use authorized_keys as a private key, which will always fail (and in fact, there's some code in the _auth function to handle the exception it's causing).
- if a system does not have an authorized keys file, it's raising an exception without attempting useful authentication methods like ssh-agent's stored keys (my preferred method).
You should simply pass an empty key list if a key isn't specified, and _auth will do the right thing, raising an SSHException if no authentication methods are available.
Also, "pub_key_file" as a variable name for a private key file is very confusing. Can we change that to priv_key_file?
Thanks, didn't realize that was still in there looks like it was in a 'testing' state and should have been removed. This is/was incomplete (and guessing broken). I did a quick update to the testing branch to show what the intention of the files is/was. By default keys in ~/.ssh/ will be iterated through (I think). The previous, an hardcoded default 'authorized_keys' was likely(hopefully) something that got left in there to test random files in that dir. I also changed the variable name(s) to key_files as a list, I think 'pub' was carried over from paramiko? Please have a look, this is a work in progress so changes very welcome. Thanks!
-M