Quantcast
Viewing all articles
Browse latest Browse all 14069

Paramiko RSAKey "private key file is encrypted"

I'm trying to use Paramiko to connect to an SFTP site.

"paramiko": {"hashes": ["sha256:6bef55b882c9d130f8015b9a26f4bd93f710e90fe7478b9dcc810304e79b3cd8","sha256:fedc9b1dd43bc1d45f67f1ceca10bc336605427a46dcdf8dec6bfea3edf57965"            ],"index": "pypi","version": "==3.0.0"        },

I have a .pem file in the form

-----BEGIN OPENSSH PRIVATE KEY-----data for the key-----END OPENSSH PRIVATE KEY-----

Worth mentioning that the key is encrypted with a passphrase.

I attempt to load the key file, providing the password and that works fine

# Works great :)mykey = paramiko.RSAKey.from_private_key_file(key_file_path, password=password)self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())# this explodesself.ssh_client.connect(hostname=settings.ftp_host, username=username, pkey=mykey, port=22)self.ftp = self.ssh_client.open_sftp()

paramiko.ssh_exception.PasswordRequiredException: private key file is encrypted

If I change the connect to

self.ssh_client.connect(hostname=settings.ftp_host, username=username, pkey=mykey, port=22, passphrase=password)

paramiko.ssh_exception.SSHException: OpenSSH private key file checkints do not match

And if I try to use key_filename instead of pkey

self.ssh_client.connect(hostname=settings.ftp_host, username=username, key_filename=key_file_path, port=22, passphrase=password)

ValueError: q must be exactly 160, 224, or 256 bits long

I am able to successfully connect to the SFTP with this key using FileZilla I'm just not sure what I'm doing wrong in Paramiko.


Viewing all articles
Browse latest Browse all 14069

Trending Articles