2

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

Vitalkaaa
  • 21
  • 2
  • Check [pysftp AuthenticationException while connecting to server with private key](https://stackoverflow.com/q/34097068/10824407). – Olvin Roght Jun 29 '22 at 18:44
  • I've tried the 'solution' from there and it didn't help. – Vitalkaaa Jun 29 '22 at 18:50
  • *"It didn't help"* doesn't help us much with identifying the problem. Post Paramiko log file + Log file of WinSCP showing a successful authentication to the same server from the same local machine using the same credentials. + Your question title is wrong. You are not *"Connecting to WinSCP"*. – Martin Prikryl Jun 29 '22 at 20:25

0 Answers0