16 Star 44 Fork 45

现任明教教主-乾颐堂 / qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.02.16 paramiko ssh执行单个命令 667 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-02-16 16:46 . new file
#!/usr/bin/python3.4
#-*- coding: utf-8 -*-
import paramiko
def copyfi(verno):
try:
ip = "10.1.1.50"
username = "admin"
passwd = "cisco"
cmd = "show config"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,22,username,passwd,timeout=5)
stdin,stdout,stderr = ssh.exec_command(cmd)
x = stdout.read().decode()
configfiletmp = '/python/DCfile/' + verno + '/' + 'FI' + '.txt'
configtmp = open(configfiletmp, 'w')
configtmp.write(x)
configtmp.close()
print('%stOKn'%(ip))
ssh.close()
except:
print('%stErrorn'%(ip))
if __name__ == '__main__':
copyfi('v2')
Python
1
https://gitee.com/qytang/qytang_Python.git
git@gitee.com:qytang/qytang_Python.git
qytang
qytang_Python
qytang_Python
master

搜索帮助