1 Star 0 Fork 457

code_source_data/CheungSSH

forked from 张其川/CheungSSH 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
GetFile.py 646 Bytes
一键复制 编辑 原始数据 按行查看 历史
张其川 提交于 2017-08-29 22:22 +08:00 . 优化部分提示
#/usr/bin/python
#coding:utf8
import paramiko,os
def GetFile(ip,port,username,password,UseKey,sfile,dfile):
dfile='/tmp/'+os.path.basename(dfile)
try:
t=paramiko.Transport((ip,port))
if UseKey=="Y":
KeyPath=os.path.expanduser('~/.ssh/id_rsa')
key=paramiko.RSAKey.from_private_key_file(KeyPath)
t.connect(username = username,pkey=key)
else:
t.connect(username = username,password = password)
sftp = paramiko.SFTPClient.from_transport(t)
ret=sftp.get(sfile,dfile)
except Exception,e:
print "不能获取获取远程服务器上的文件(%s)"%e
return False
else:
t.close()
print "+Get File is OK"
return True
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/code_source_data/CheungSSH.git
git@gitee.com:code_source_data/CheungSSH.git
code_source_data
CheungSSH
CheungSSH
master

搜索帮助