#-*- coding: utf-8 -*- # Paramiko modülünü kullanıp ssh işlemlerini yapabilen basit bir sınıf. # Copyright (C) 2008 Ömer ÜCEL import os import paramiko class SimpleSsh: """ ssh = SimpleSsh(host,username,password,port) ssh.upload(local_file,remote_file) ssh.download(remote_file,local_file) del ssh """ def __init__(self,host,username,password,port=22): self.host = host self.username = username self.password = password self.port = port self.ssh = paramiko.SSHClient() self.connect() def __del__(self): self.disconnect() def connect(self): self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.ssh.connect(self.host,self.port,self.username,self.password) self.sftp = self.ssh.open_sftp() def disconnect(self): self.ssh.close() def upload(self,localpath,remotepath): self.sftp.put(localpath,remotepath) def download(self,remotepath,localpath): self.sftp.get(localpath,remotepath)