Giter VIP home page Giter VIP logo

swiftsh's Introduction

SwiftSH

This is a fork of the original SwiftSH module with a handful of bug fixes and changes that I wanted for my SwiftTerm emulator. The upstream package does not seem active.

While Carthage, Pods and other platforms were originally supported, I have not attempted to update those, I have now moved to SwiftPM for it, which solved various issues for me.

Additionally, this add a callback-based authentication system, that you can now use for authenticating using the secure enclave.

Original Readme

Carthage compatible Pods Pod platforms

A Swift SSH framework that wraps libssh2.

Features:

  • Thread-safety
  • SSH shell
  • SSH command
  • SCP
  • SFTP
  • Tests
  • Documentation

๐Ÿ“ฆ Installation

CocoaPods

CocoaPods is the dependency manager for Swift and Objective-C Cocoa projects. It has over ten thousand libraries and can help you scale your projects elegantly.

Add this to your Podfile:

use_frameworks!

pod 'SwiftSH'

Carthage

Carthage builds your dependencies and provides you with binary frameworks, but you retain full control over your project structure and setup.

Add this to your Cartfile:

github "Frugghi/SwiftSH"

๐Ÿ“– Documentation

The API documentation is available here.

๐Ÿ’ป Usage

Import the framework:

import SwiftSH

Execute a SSH command:

let command = Command(host: "localhost", port: 22)
// ...
command.connect()
       .authenticate(.byPassword(username: "username", password: "password"))
       .execute(command) { (command, result: String?, error) in
           if let result = result {
               print("\(result)")
           } else {
               print("ERROR: \(error)")
           }
       }

Open a SSH shell:

let shell = Shell(host: "localhost", port: 22)
// ...
shell.withCallback { (string: String?, error: String?) in
         print("\(string ?? error!)")
     }
     .connect()
     .authenticate(.byPassword(username: "username", password: "password"))
     .open { (error) in
         if let error = error {
             print("\(error)")
         }
     }
// ...
shell.write("ls -lA") { (error) in
    if let error = error {
        print("\(error)")
    }
}
// ...
shell.disconnect()

โš ๏ธ OpenSSL and Libssh2 binaries

SwiftSH includes precompiled binaries of Libssh2 and OpenSSL generated with this script. For security reasons, you are strongly encouraged to recompile the libraries and replace the binaries.

๐Ÿ“„ License LICENSE

SwiftSH is released under the MIT license. See LICENSE for details.

swiftsh's People

Contributors

thetekton337 avatar frugghi avatar migueldeicaza avatar jpalten avatar jesper-bylund avatar jessearmand avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.