使用Python加载RFC4716 SSH密钥

时间:2019-06-23 06:24:11

标签: python ssh pycrypto pycryptodome

我正在尝试以SSH2格式打开密钥-开头为:

-----BEGIN OPENSSH PRIVATE KEY-----

带有pycryptodome。它没用。

>>> from Crypto.PublicKey import RSA
>>> k = open('bad').read()
>>> RSA.import_key(k)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/maciekw/dev/lamamind/aws-key-managemnt/venv/lib/python3.7/site-packages/Crypto/PublicKey/RSA.py", line 736, in import_key
    return _import_keyDER(der, passphrase)
  File "/home/maciekw/dev/lamamind/aws-key-managemnt/venv/lib/python3.7/site-packages/Crypto/PublicKey/RSA.py", line 679, in _import_keyDER
    raise ValueError("RSA key format is not supported")
ValueError: RSA key format is not supported

还有其他图书馆可以做到吗?我需要它将密钥转换为DER格式,并以EC2的方式计算指纹。

0 个答案:

没有答案