monsterwell/classes/server.py
2023-01-09 17:18:59 +00:00

22 lines
818 B
Python

import paramiko
class Server:
def __init__(self, host, username, password, inpath, outpath, ourkey, theirkey):
self.host = host
self.username = username
self.password = password
self.inpath = inpath
self.outpath = outpath
self.ourkey = ourkey
self.theirkey = theirkey
@classmethod
def from_config(cls, section):
return cls(section["Host"], section["Username"], section["Password"], section["InPath"], section["OutPath"], section["OurKey"], section["TheirKey"])
def get_sftp_client(self):
ssh_client = paramiko.SSHClient()
ssh_client.load_system_host_keys()
ssh_client.connect(self.host, username=self.username, password=self.password)
sftp_client = ssh_client.open_sftp()
return sftp_client