I am trying to connect to SFTP server. I have a private key along with a password. I have tried to read related questions on SO, but have been unable to successfully connect.
This is what I have tried:
pysftp.Connection(host=<hostname>, username=<username>,
password=<password>, private_key=<path to .ppk file>)
AuthenticationException: Authentication failed
pysftp.Connection(host=<hostname>, username=<username>,
private_key_pass=<password>, private_key=<path to .ppk file>)
SSHException: not a valid DSA private key file
However, I can use the same credentials and connect with FileZilla. FileZilla asked for password and converted the .ppk
file into an unprotected file.
I tried to use the same host name, username and key file as used in FileZilla, but I continue getting errors. Also tried connecting using Paramiko.
I could finally connect.
Converted the file to a .pem
file using PuTTY. Passed this .pem
file and kept the rest of the parameters the same as before.
pysftp.Connection(host='hostname', username='username',
password='password', private_key='path to .pem file')
Hope this helps someone having similar issues.