Paramiko: "not a valid RSA private key file" on Mac

Created on 3 Dec 2018  路  3Comments  路  Source: paramiko/paramiko

I have the following code:

ssh_key = paramiko.RSAKey.from_private_key_file(key_filename)

the key looks like this:

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAQEAqdgmJ2AQlmvpCsDWjbpIvIrx4AwtKn2t10wmGZIN9pqcJgQpo3HD

and is valid:

 $ ssh-keygen -l -f <mykeyfile>
 $ 2048 SHA256:x8jlUAObU3q2KXRtuGpxwhnGvB/ZoeD2IUqSA1OkCmI thomas@Thomas-MBP-2017 (RSA)

but I get the "not a valid RSA private key file" error.
this is on MacOS, Python 2.7, Paramiko 2.4.2

what am I doing wrong?

Most helpful comment

@thomasd3 You should look into this
https://serverfault.com/questions/939909/ssh-keygen-does-not-create-rsa-private-key

you can use below command to generate RSA based key and can use existing paramiko libraries
ssh-keygen -t rsa -m PEM

All 3 comments

I think you may need #1343

thanks!

@thomasd3 You should look into this
https://serverfault.com/questions/939909/ssh-keygen-does-not-create-rsa-private-key

you can use below command to generate RSA based key and can use existing paramiko libraries
ssh-keygen -t rsa -m PEM

Was this page helpful?
0 / 5 - 0 ratings