2011-10-25 61 views
0

我正在寫python腳本來使用paramiko登錄到ssh服務器。 我在下面寫了腳本。在Python腳本中獲取錯誤「AttributeError:'模塊'對象沒有屬性'auth_none'」

#!/usr/bin/python 

import paramiko 
ssh = paramiko.SSHClient() 
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
paramiko.transport.auth_none('sachin') 
ssh.connect('localhost', username='sachin', password='abc123') 
stdin, stdout, stderr = ssh.exec_command('df -h') 
print stdout.readlines() 
ssh.close() 

現在越來越誤差低於 AttributeError的:「模塊」對象有沒有屬性「AUTH_NONE」

任何人都知道爲什麼我收到此錯誤

謝謝!

回答

2

paramiko.transport模塊不包含名稱auth_none,如可從其documentation(以及錯誤消息)中看到的那樣。

也許你想

ssh.get_transport().auth_none('sachin') 
2

auth_none必須要求特定Transport實例,而不是transport模塊。

由於SSHClient沒有相應的設置,因此您必須改用原始Transport

相關問題