1
votes

I have to connect to a remote sftp server to upload some files using python 2.7. i have been given a username, password and the authentication key file. when i execute this code:

srv= pysftp.Connection(host='54.172.33.121',username='xxx',password='xxx',private_key='c:\SFTPKey\hajjcoreit.ppk')

i get this error:

BadAuthenticationType: ('Bad authentication type', [u'publickey']) (allowed_types=[u'publickey'])

i can access the server through winSCP though.

1

1 Answers

0
votes

Edits in your code

You probably have done something wrong with the hostname. As the proper syntax for pysftp is as

import pysftp
sftp = pysftp.Connection('hostname', username='me', password='secret')
#
# ... do sftp operations
#
sftp.close()    # close your connection to hostname

so now this is what you do,

srv=pysftp.Connection('sftp.54.172.33.121',username='xxx',password='xxx',private_key='c:\SFTPKey\hajjcoreit.ppk')

so you won't get any error.Also cross check with the filezilla that the link, uid and password are correct.