Home > Backend Development > Python Tutorial > An example of using paramiko to remotely copy files in python

An example of using paramiko to remotely copy files in python

高洛峰
Release: 2017-03-04 16:40:36
Original
1865 people have browsed it

The example of this article describes how python uses paramiko to realize remote copying of files. Share it with everyone for your reference, the details are as follows:

The first is to install the paramiko library (which implements the SSH2 security protocol), which can be installed directly from the source under ubuntu:

sudo apt-get install python-paramiko
Copy after login

The next step is the code to implement remote download:

def remote_scp(host_ip,remote_path,local_path,username,password):
  t = paramiko.Transport((host_ip,22))
  t.connect(username=username, password=password) # 登录远程服务器
  sftp = paramiko.SFTPClient.from_transport(t)  # sftp传输协议
  src = remote_path
  des = local_path
  sftp.get(src,des)
  t.close()
Copy after login

For more examples of python using paramiko to achieve remote copying of files, please pay attention to the PHP Chinese website for related articles. !

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template