Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better differenciation between SSHException in PKey #1683

Open
cybiere opened this issue May 12, 2020 · 0 comments
Open

Better differenciation between SSHException in PKey #1683

cybiere opened this issue May 12, 2020 · 0 comments

Comments

@cybiere
Copy link

cybiere commented May 12, 2020

Hi,
I'm trying to identify whether an arbitrary file is (1) a SSH private key, (2) using which algo, (3) if it has a passphrase and if yes (4) if the passphrase I provide is valid.

I use a trial and error process basing myself on the exceptions raised, so if I need a passphrase I have paramiko.ssh_exception.PasswordRequiredException telling me so. If I try to load an ECDSA with paramiko.RSAKey.from_private_key_file, I have an paramiko.ssh_exception.SSHException. But if I try to load a RSA key with the same line using a wrong passphrase, I still have a SSHException, and I must check the string value of the exception to differenciate (if "checkints do not match" in str(e):)

It would be great to have for instance a paramiko.ssh_exception.InvalidPasswordException (raised in pkey.py line 477) so that people (at least I :D ) don't have to rely on parsing the error string :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant