def connection_factory type
      config = Myreplicator.configs[self.source_schema]
      puts self.source_schema
      puts config
      case type
      when :ssh
        if config.has_key? "ssh_password"
          return Net::SSH.start(config["ssh_host"], config["ssh_user"], :password => config["ssh_password"])

        elsif(config.has_key? "ssh_private_key")
          return Net::SSH.start(config["ssh_host"], config["ssh_user"], :keys => [config["ssh_private_key"]])
        end
      when :sftp
        if config.has_key? "ssh_password"
          return Net::SFTP.start(config["ssh_host"], config["ssh_user"], :password => config["ssh_password"])

        elsif(config.has_key? "ssh_private_key")
          return Net::SFTP.start(config["ssh_host"], config["ssh_user"], :keys => [config["ssh_private_key"]])
        end          
      end
    end
def connection_factory type
      config = Myreplicator.configs[self.source_schema]
      puts self.source_schema
      puts config
      case type
      when :ssh
        if config.has_key? "ssh_password"
          return Net::SSH.start(config["ssh_host"], config["ssh_user"], :password => config["ssh_password"])

        elsif(config.has_key? "ssh_private_key")
          return Net::SSH.start(config["ssh_host"], config["ssh_user"], :keys => [config["ssh_private_key"]])
        end
      when :sftp
        if config.has_key? "ssh_password"
          return Net::SFTP.start(config["ssh_host"], config["ssh_user"], :password => config["ssh_password"])

        elsif(config.has_key? "ssh_private_key")
          return Net::SFTP.start(config["ssh_host"], config["ssh_user"], :keys => [config["ssh_private_key"]])
        end          
      end
    end
Connects to the server via ssh/sftp