我不知道這是否是正確的方式來做到這一點,但它似乎在我的情況下工作:
def interactive_auth_handler(title, instructions, prompt_list):
if prompt_list:
if prompt_list[0][0]=="AD Password: ":
return [password]
return [getpass.getpass(prompt_list[0][0])]
return []
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(host, port, username=username, password=password, pkey=None)
except paramiko.ssh_exception.SSHException as e:
transport = client.get_transport()
transport.auth_interactive(username, interactive_auth_handler)
你是指鍵盤交互? –
我這麼認爲,因爲密碼輸入前短信密碼沒有發送 –