@myles
2018-08-02T16:40:40.000000Z
字数 515
阅读 686
未分类
学习参考:http://www.ywnds.com/?p=11494
https://www.youtube.com/watch?v=CKVMwte8Z-s
# coding:utf-8
import paramiko
def sshclient():
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname="192.168.31.56", port=22, username="myles", password="toor", timeout=10)
stdin,stdout,stderr = client.exec_command('ifconfig')
client.close()
return stdout
stdout = 1
n = 0
try:
while stdout:
sshclient()
if stdout:
n += 1
print("登录{}成功...".format(n))
except:
print("登录{}次时,测试失败...".format(n))