2016-05-29 41 views
0

我必須使用pysftp庫連接到其他服務器的python,目標服務器有一個關鍵值對文件(pem文件),而且我有但以下情況除外:pysftp連接到pem文件引發異常的主機paramiko.ssh_exception.BadAuthenticationType

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

我的代碼:

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

請任何幫助嗎?我該如何解決這個問題?

回答

1

從文檔:

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

正如你可以看到有沒有password= "no password",在療法。嘗試一下,只需在代碼中省略它,因爲它可能會觸發使用用戶名/密碼身份驗證,從而跳過您的private_key。

相關問題