Latest0.1.2
Homepagehttps://github.com/Frugghi/SwiftSH
LicenseMIT
Platformsios 8.0, requires ARC
Authors

Build Status
Carthage compatible
Pods
Pod platforms

A Swift SSH framework that wraps libssh2.

Features:

  • [x] Thread-safety
  • [x] SSH shell
  • [x] SSH command
  • [ ] SCP
  • [ ] SFTP
  • [ ] Tests
  • [ ] Documentation

:package: 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"

:book: Documentation

The API documentation is available here.

:computer: 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()

:warning: 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.

:page_facing_up: License LICENSE

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

Latest podspec

{
    "name": "SwiftSH",
    "version": "0.1.2",
    "summary": "A Swift SSH framework that wraps libssh2.",
    "homepage": "https://github.com/Frugghi/SwiftSH",
    "license": "MIT",
    "authors": {
        "Tommaso Madonia": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Frugghi/SwiftSH.git",
        "tag": "0.1.2"
    },
    "requires_arc": true,
    "default_subspecs": "Libssh2",
    "swift_version": "4.1",
    "platforms": {
        "ios": "8.0"
    },
    "subspecs": [
        {
            "name": "Core",
            "source_files": "SwiftSH/*.swift",
            "exclude_files": "SwiftSH/Libssh2*"
        },
        {
            "name": "Libssh2",
            "dependencies": {
                "SwiftSH/Core": []
            },
            "libraries": "z",
            "preserve_paths": "libssh2",
            "source_files": "SwiftSH/Libssh2*.{h,m,swift}",
            "pod_target_xcconfig": {
                "VALID_ARCHS[sdk=iphonesimulator*]": "x86_64",
                "SWIFT_INCLUDE_PATHS": "$(PODS_ROOT)/SwiftSH/libssh2",
                "LIBRARY_SEARCH_PATHS": "$(PODS_ROOT)/SwiftSH/libssh2",
                "HEADER_SEARCH_PATHS": "$(PODS_ROOT)/SwiftSH/libssh2"
            }
        }
    ]
}

Pin It on Pinterest

Share This