亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区
Chinaunix
標(biāo)題:
paramiko問(wèn)題
[打印本頁(yè)]
作者:
robberboyboy
時(shí)間:
2016-03-12 17:51
標(biāo)題:
paramiko問(wèn)題
最近在學(xué)習(xí)python ,網(wǎng)上看了下關(guān)于自動(dòng)登錄linux服務(wù)器的代碼,copy下來(lái)聯(lián)系了下發(fā)現(xiàn)了些問(wèn)題:
有的機(jī)器是可以登錄的沒(méi)有問(wèn)題,但是同時(shí)用了GSS-API authentication , ssh用root密碼是可以登錄的,但是用paramiko模塊不行
提示:設(shè)置了allow_agent=False,look_for_keys=False 依舊
DEBUG:paramiko.transport:userauth is OK
DEBUG:paramiko.transport:Authentication type (password) not permitted.
DEBUG:paramiko.transport:Allowed methods: [u'publickey', u'keyboard-interactive']
代碼如下:
import sys
import paramiko
import threading
def ssh2(ip,username,passwd,cmd):
try:
paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,22,username,passwd,allow_agent=False,look_for_keys=False)
for m in cmd:
stdin,stdout,stderr = ssh.exec_command(m)
stdin.write("y")
out = stdout.readlines()
for o in out:
print(o)
print('{}\tOK\n'.format(ip))
ssh.close()
except paramiko.ssh_exception.BadAuthenticationType:
print('BadAuthenticationType')
except paramiko.ssh_exception.AuthenticationException:
print('AuthenticationException')
except paramiko.ssh_exception.BadHostKeyException:
print('BadHostKey')
except:
print('{}\tError\n'.format(ip))
if __name__=='__main__':
cmd = ['shutdown -h now']
username ='root'
passwd = 'tencent'
threads = []
ip='192.168.120.128'
a=threading.Thread(target=ssh2,args=(ip,username,passwd,cmd))
a.start()
歡迎光臨 Chinaunix (http://72891.cn/)
Powered by Discuz! X3.2