Connect to WinSCP with private key and private key pass using Python Pysftp

Viewed 127

I'm trying to connect to SFTP server. When I use WinSCP application directly with login, password, host and private key it works perfectly. But I want to write a script which will download some data every day.

import pysftp as sftp

Hostname = "some_host"
username = "user"
password = "password"
privateKey = "path to key"


with sftp.Connection(host=Hostname, port=22, username=username, password=password, private_key=privateKey,  private_key_pass=password) as sftp:
    print("Connection successfully established ... ")
    sftp.listdir()

and I have

paramiko.ssh_exception.AuthenticationException: Authentication failed.

I've tried this on pysftp 0.2.8 and pysftp 0.2.9. I have private key in .ppk format but also tried to convert it into .pem but this didn't help.

Please help o(^_^)o

0 Answers
Related