1 Star 2 Fork 0

凡凡世界 / script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ssh1.py 759 Bytes
一键复制 编辑 原始数据 按行查看 历史
凡凡世界 提交于 2014-03-05 09:53 . add ssh scripts
#-*- 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)
Python
1
https://gitee.com/fanfan/script.git
git@gitee.com:fanfan/script.git
fanfan
script
script
master

搜索帮助