Home > Article > Backend Development > An example of using paramiko to remotely copy files in python
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
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()
For more examples of python using paramiko to achieve remote copying of files, please pay attention to the PHP Chinese website for related articles. !