import os
import paramiko

def RemoteScp(host_ip, host_port, host_username, host_password, remote_path, local_path):
scp = paramiko.Transport((host_ip, host_port))
scp.connect(username=host_username, password=host_password)
sftp = paramiko.SFTPClient.from_transport(scp)
try:
remote_files = sftp.listdir(remote_path)
for file in remote_files:
local_file = local_path + file
remote_file = remote_path + file
sftp.get(remote_file, local_file)
except IOError:
return ("remote_path or local_path is not exist")
scp.close()

if __name__ == '__main__':
host_ip = '192.168.1.100'     --源端IP
host_port = 22    --源端SSH端口
host_username = 'root'  --源端用户名
host_password = '12345678'  --源端密码
remote_path = '/orabak/baktmp/'  --源端存放备份集路径
local_path = '/bak/scorabak/'    --目的端路径
RemoteScp(host_ip, host_port, host_username, host_password, remote_path, local_path)

Ansible scp Python脚本的更多相关文章

  1. ansible批量分发免密钥登陆python脚本

    最近看了看强大的号称自动化运维的三大利器之一的--ansible,ok,亲测之后,确实感觉,对于我们这种DBA工作者来说,确实很受益. 值得注意的是ansible要求被管理服务器python版本不低于 ...

  2. 使用python脚本实现基于指定字符串的文本排序

    朋友用ansible导出了一个文件,文件中包含上千台机器的磁盘信息,他想要知道哪些机器最需要赶紧扩磁盘.思路是,按剩余磁盘空间百分数,从小到大对文本内容重新排序.下面是具体实现. 源文件ip.txt的 ...

  3. ansible配合shell脚本批量编译安装python3.6.6

    [root@node1:/etc]# tree /etc/ansible/ /etc/ansible/ ├── ansible.cfg ├── hosts ├── python.yml └── rol ...

  4. nginx tomcat 自动部署python脚本【转】

    #!/usr/bin/env python #--coding:utf8-- import sys,subprocess,os,datetime,paramiko,re local_path='/ho ...

  5. freeswitch嵌入python脚本

    操作系统:debian8.5_x64 freeswitch 版本 : 1.6.8 python版本:2.7.9 开启python模块 安装python lib库 apt-get install pyt ...

  6. python脚本后台运行

    问题描述: 环境: CentOS6.4 一个用python写的监控脚本test1.py,用while True方式一直运行,在ssh远程(使用putty终端)时通过以下命令启动脚本: python t ...

  7. 某互联网后台自动化组合测试框架RF+Sikuli+Python脚本

    某互联网后台自动化组合测试框架RF+Sikuli+Python脚本 http://www.jianshu.com/p/b3e204c8651a 字数949 阅读323 评论1 喜欢0 一.**Robo ...

  8. 动态执行python脚本

    前言 存在许多独立的python脚本,这些脚本可能会增加,也可能会减少,现在需要按照某种顺序调度这些程序.在python的standard library中,有一个模块imp可以实现动态的调用ptho ...

  9. 一个获取指定目录下一定格式的文件名称和文件修改时间并保存为文件的python脚本

    摘自:http://blog.csdn.net/forandever/article/details/5711319 一个获取指定目录下一定格式的文件名称和文件修改时间并保存为文件的python脚本 ...

  10. SecureCRT中python脚本编写

    SecureCRT中python脚本编写学习指南 SecureCRT python 引言 在测试网络设备中,通常使用脚本对设备端进行配置和测试以及维护:对于PE设备的测试维护人员来说使用较多是Secu ...

随机推荐

  1. ArcGIS工具 - 按字段分割图层

    天下大势,合久必分,分久必合.合并.分割在GIS数据处理和管理中也十分常见,例如按行政区划名称导出多个区县行政图层.按地类名称导出多个地类图层. 功能说明 其实,在ArcGIS中除了按属性导出外,最接 ...

  2. C Primer Plus 5.11 編程練習

    /*C Primer Plus (5.10) 9*/ 1 #include<stdio.h> 2 #define G 103 3 int main() 4 { 5 char ch=96; ...

  3. 10月28日内容总结——ATM项目开发流程

    目录 一.项目开发流程 1.项目需求分析: 2.项目架构设计: 3.项目分组开发: 4.项目提交测试: 5.项目交付上线: 二.项目需求分析 1.主题 2.项目核心 3.项目需求: 4.从需求中提炼出 ...

  4. 数据采集之刷cnblog评论

    python代码如下: import random import time import requests cookies = { '__gads': 'ID=3c504aa17c4a7048:T=1 ...

  5. IIS重定向HTTP至HTTPS

    一.安装URL重写模块,自行百度下载 二.选择网站进行添加规则 三.总结 其实就是在站点的Web.config增加了一段配置: <system.webServer> <rewrite ...

  6. 6、Collections工具类

    1.Collections工具类介绍 Collections 是一个操作 Set.List 和 Map 等集合的工具类 Collections 中提供了一系列静态的方法对集合元素进行排序.查询和修改等 ...

  7. Syntax Error: Error: Cannot find module ‘node-sass‘

    出现问题原因: vscode运行前端项目输入npm run dev命令触发此错误 解决办法: 指定淘宝镜像安装node-sass win+r 打开cmd控制台输入 npm install -g cnp ...

  8. ubuntu 备份系统

    1.安装Systemback: sudo add-apt-repository ppa:nemh/systemback sudo apt-get update sudo apt-get install ...

  9. python3使用requests模块发https请求,提示caused by ssl error, can't connect to https url because the ssl module is not available

    Q: python3使用requests模块发https请求,提示caused by ssl error, can't connect to https url because the ssl mod ...

  10. vue中央事件

    详情请看这个链接https://blog.csdn.net/sinat_17775997/article/details/59025563