# PythonSftp **Repository Path**: dawn_yunwii/PythonSftp ## Basic Information - **Project Name**: PythonSftp - **Description**: Python写的使用sftp上传文件 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2016-05-20 - **Last Updated**: 2021-07-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #PythonSftp 使用 git 地址:http://git.oschina.net/dawn_yunwii/PythonSftp ###简介 PythonSftp,使用python代码编写的,使用sftp协议,来实现,向远端Linux服务器,copy文件的工具。 依赖:`paramiko` 如果没有安装`paramiko`, 先要执行`pip install paramiko`安装`paramiko` 如果没有安装`pip`,先安装`pip` ###配置文件参数说明 项目中有example.json文件作为参考 [ { "server_name":"随便起个名字,便于标识", "host":"IP地址", "username":"用户名", "password":"密码", "path_config":[ { "dir_local":"/Users/example/git/hexo/public/", "dir_remote":"/usr/local/hexo", "exclude":[*node*,*src*] } ], "global_ignore_file":[ "*.DS_Store" ], "config_path":"/usr/local/tomcat8-online/webapps/ROOT/WEB-INF", "config_path_local":"/Users/weijianxing/Desktop/config/spark/spark-product", "port":"22", "copy_config":"false" } ] 参数说明: `path_config`是一个数组,可以配置多个需要上传的路径; `dir_local`:是你本机要上传的文件目录 `dir_remote`:是你要上传到远端服务器的目录 `exclude`:是一个数组,排除的不需要拷贝的文件,支持正则表达式匹配。 举例:\*node*,比如/example/node_modules/apps/.. 这个目录就会被忽略掉 `global_ignore_file`:全局的忽略文件,`path_config`中的目录下的这个文件都会被忽略都会被忽略 `config_path`:服务器的配置文件,跟本地的配置文件一般不同,避免上传文件把配置文件覆盖,所以在本地备份一份配置文件,然后上传文件时,把配置文件也覆盖 ###运行 修改`ssh_deploy.py`的代码 最后一行,`start_deploy('example.json')`,把这里写上你写的配置文件 然后执行`python ssh_deploy.py`就执行了