Need to use paramiko library

 

Upload local files to the server . Add the ip,port,username,password Complete supplement , Use it uploadfiletoserver Function to upload local files to the server
import paramiko ip = ""# The server ip port = 22# Port number username = "root"# user name password =
""# password def
uploadfiletoserver(local,remote):# Upload file to server .local Is the local path to upload the file ;remote Is the path to upload to the server
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(ip, port,
username, password) sftp = ssh.open_sftp() sftp.put(local, remote) return remote
 

Remote open server file :
import paramiko ip = ""# The server ip port = 22# Port number username = "root"# user name password =
""# password def openremotefile(filepath):#filepath Is the absolute path to the file to be opened on the server client =
paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(ip,
port, username, password, compress=True) sftp_client = client.open_sftp()
remotefile = sftp_client.open(filepath) # File path return remotefile
 

All codes
import paramiko ip = ""# The server ip port = 22# Port number username = "root"# user name password =
""# password def
uploadfiletoserver(local,remote):# Upload file to server .local Is the local path to upload the file ;remote Is the path to upload to the server
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(ip, port,
username, password) sftp = ssh.open_sftp() sftp.put(local, remote) return
remote def openremotefile(filepath):#filepath Is the absolute path to the file to be opened on the server client =
paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(ip,
port, username, password, compress=True) sftp_client = client.open_sftp()
remotefile = sftp_client.open(filepath) # File path return remotefile
 

Technology
©2020 ioDraw All rights reserved
【webpack】DLL plugin Principle analysis Combined with source code Transformer The most comprehensive , The deepest analysis filemanager-webpack-plugin Turn resources into zip Package and archive JavaScript study ( Function declaration and parameters ) mean value - Implementation and application of variance model _python_ Data analysis _9JAVA Snake games ( Source code + notes )SpringBoot integrate Redisson Implement delay queue python code , Easy to complete Snake games Thread.setDaemon Set up the Daemons Unity Code dynamic creation of preform in editor expansion function