pysftp connection to host with pem file raise exception paramiko.ssh_exception.BadAuthenticationType
Question: I have to connect to other server in python using the pysftp library, the
target server had a key value pair file (pem file), and I've got the following
exception:

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

my Code:

    
    
    import pysftp
     pysftp.Connection(host="<IP address>", username="myUserName", password="no password", port=22, private_key="myPemFilePath.pem")
    

Please any help? and how can I fix such like this issue ?


Answer: From the documentation :

    
    
    import pysftp
    with pysftp.Connection('hostname', username='me', private_key='/path/to/keyfile') as sftp:
        #
        # ... do sftp operations
        #
    

As you can see there is no `password= "no password"`, in ther. Try, by just
omitting that in your code, as it probably triggers the use of
username/password authentication, skipping your private_key.

