代码拉取完成,页面将自动刷新
#-*- coding: utf-8 -*-
#!/usr/bin/python
import paramiko
def ssh1(ip, username, passwd, cmd):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, 22, username, passwd, timeout=5)
for m in cmd:
studin, stdout, stderr = ssh.exec_command(m)
# stdin.write("yes")
out = stdout.readlines()
for o in out:
print o,
print '%s\tOK\n' %(ip)
ssh.close()
except:
print '%s\tError\n' %(ip)
if __name__ == '__main__':
cmd = ['cal', 'echo hello']
username = "root"
passwd = "123.com"
ip="10.33.1.241"
print "Begin......"
ssh1(ip, username, passwd, cmd)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。