def loginandcopydir(hostname,uname,pwd,sfile,tfile,recursive,preserve_times):
try:
log.info("Establishing ssh connection")
client = getsshClient()
client.load_system_host_keys()
client.connect(hostname) #,username=uname)#,password=pwd)
except paramiko.AuthenticationException:
print("Authentication failed, please verify your credentials: %s")
except paramiko.SSHException as sshException:
print("Unable to establish SSH connection: %s" % sshException)
except paramiko.BadHostKeyException as badHostKeyException:
print("Unable to verify server's host key: %s" % badHostKeyException)
except Exception as e:
print(e.args)
try:
scpclient = scp.SCPClient(client.get_transport())
scpclient.put(sfile,tfile,recursive,preserve_times)
except scp.SCPException as e:
print("Operation error: %s", e)
# Deprecated
paramiko_helper.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录