29 lines
830 B
Python
29 lines
830 B
Python
import paramiko
|
|
|
|
class CustomSFTPClient():
|
|
def __init__(self):
|
|
host = "192.168.200.230"
|
|
port = 22
|
|
id = "fermat"
|
|
pw = "1234"
|
|
|
|
self.ssh_client = paramiko.SSHClient()
|
|
self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
self.ssh_client.connect(hostname=host, port=port, username=id, password=pw)
|
|
|
|
self.sftp_client = self.ssh_client.open_sftp()
|
|
|
|
def remote_mkdir(self, remote_path):
|
|
self.sftp_client.mkdir(remote_path)
|
|
|
|
def remote_copy_data(self,local_path, remote_path):
|
|
self.sftp_client.put(local_path, remote_path)
|
|
|
|
def client_close(self):
|
|
self.sftp_client.close()
|
|
self.ssh_client.close()
|
|
|
|
sftp_client = None
|
|
|
|
if sftp_client is None:
|
|
sftp_client = CustomSFTPClient() |