nmssh

Welcome to the nmSSH Documentation

Introduction

nmSSH is a lightweight SSH library for iOS and macOS development. It provides an easy-to-use interface for connecting to remote servers, executing commands, and transferring files securely over SSH.

Features

  • Simple and intuitive API.
  • Supports SSHv2 protocol.
  • Securely execute commands on remote servers.
  • Transfer files between local and remote machines.
  • Support for password authentication and public key authentication.
  • Thread-safe design for multithreaded environments.
  • Extensive error handling and error reporting.

Installation

To use nmSSH in your iOS or macOS project, you can either install it manually or through a dependency manager.

Manual Installation

  1. Download the nmSSH framework from the official GitHub repository.
  2. Drag and drop the nmSSH framework into your Xcode project.
  3. Add the necessary frameworks and libraries to your project settings:

SystemConfiguration.framework
libz.tbd
libresolv.tbd

Using CocoaPods

If you prefer to use CocoaPods, you can add nmSSH to your Podfile:

pod 'nmSSH'

Then, run the following command in Terminal:

pod install

Usage

nmSSH provides a straightforward API for interacting with SSH servers. Here is a basic example to get you started:

// Import the nmSSH framework
import nmSSH

// Create an instance of nmSSHSession
let session = nmSSHSession(host: "example.com", username: "myUsername")

// Enable public key authentication
session.authenticateByPublicKey(privateKey: "private_key_path", publicKey: "public_key_path", passphrase: "passphrase")

// Connect to the remote server
if session.connect() {
    print("Connected successfully!")

    // Execute a command on the remote server
    let commandResult = session.executeCommand("ls -l")
    print("Command output: \(commandResult)")

    // Transfer a file from the local machine to the remote server
    let fileTransferResult = session.sendFile(localPath: "local_file_path", remotePath: "remote_file_path")
    if fileTransferResult {
        print("File transfer successful!")
    } else {
        print("File transfer failed.")
    }

    // Disconnect from the server
    session.disconnect()
} else {
    print("Connection failed.")
}

Additional Resources

For more information and advanced usage of nmSSH, you can refer to the following resources:

  1. nmSSH GitHub repository
  2. nmSSH Wiki
  3. nmSSH Issue Tracker

License

nmSSH is released under the MIT License. Please see the LICENSE file for more details.