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

bug of parsing new format keys #1565

Closed
huashengdun opened this issue Dec 5, 2019 · 3 comments
Closed

bug of parsing new format keys #1565

huashengdun opened this issue Dec 5, 2019 · 3 comments

Comments

@huashengdun
Copy link

Screenshot from 2019-12-05 18-02-11

From the screenshot above, you see parsing dsa ed25519 keys succeeded, parsing rsa ecdsa keys failed.
The interesting part is parsing rsa key, paramiko recognize it as both rsa and dss type key.

@huashengdun
Copy link
Author

huashengdun commented Dec 5, 2019

generate dsa ecdsa ed25519 rsa private keys

for t in dsa ecdsa ed25519 rsa; do ssh-keygen -t $t -f id_$t -q -N "" && rm *.pub; done

parse.py

import sys
from paramiko import DSSKey, ECDSAKey, Ed25519Key, RSAKey


filenames = sys.argv[1:]
keyclasses = [DSSKey, ECDSAKey, Ed25519Key, RSAKey]


for filename in filenames:
    print('Parsing {}'.format(filename))
    print('='*20)
    for keycls in keyclasses:
        try:
            print(keycls.__name__, end=' ')
            key = keycls(filename=filename)
        except Exception as e:
            print('x')
        else:
            print('√')
        print('-'*20)
    print()

@ploxiln
Copy link
Contributor

ploxiln commented Dec 5, 2019

The bug with new-format ECDSAKey was mentioned here: #1343 (comment) (and was not addressed in that pull-request, but I think the maintainer was under the impression that it was addressed)

@huashengdun
Copy link
Author

huashengdun commented Dec 11, 2019

Notice the bug of parsing RSA key still has not been fixed yet.
Although paramiko can recognize the RSA type key correctly, but there are still chances that paramiko recognizes the RSA key as the DSS type key.

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

2 participants