Skip to content
/ NMSSH Public
forked from NMSSH/NMSSH

NMSSH is an Objective-C wrapper for libssh2, with a sweet API.

License

Notifications You must be signed in to change notification settings

afardel/NMSSH

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NMSSH

This is a complete rewrite of the previous NMSSH library. The goal is to create a clean, easy-to-use, test driven Cocoa framework that wraps libssh2.

NMSSH was initially built for usage in Kleio - a Mac OSX application that simplifies continuous deployment.

Framework completion status: 5 %
Using libssh2 version: 1.4.2

Are you using NMSSH for something cool? Let me know.

Usage

Install the framework

  • Build the framework and add it to your project
  • Add #include <NMSSH/NMSSH.h> to your source file.

Connect to a server (not yet implemented)

1. Create a new session

NMSSHSession *session = [NMSSHSession connectToHost:@"127.0.0.1:22"
                                       withUsername:@"user"];

if ([session isConnected]) {
    NSLog(@"Successfully created a new session");
}

2.1. Authenticate by password

[session authenticateByPassword:@"pass"];

2.2. Or by public key

// Explicitly set the public key that should be used...
// Pass nil as password parameter for unprotected keys
[session authenticateByPublicKey:@"~/.ssh/id_rsa.pub"
                     andPassword:@"pass"];

2.3. Or connect to a SSH agent

[session connectToAgent];

3. Check if authentication was successful

if ([session isAuthorized]) {
    NSLog(@"Authentication succeeded");
}

4. Don't forget to disconnect

[session disconnect];
session = nil;

Using Channels (not yet implemented)

NSString *response = [session execute:@"echo foo"];
NSLog(@"Response: %@", response);

SCP file transfer (not yet implemented)

The SCP API provides a simple way to upload or download files.

The to: parameter is flexible in that if you provide a directory, it will keep the same filename as in the from-parameter. But if you provide a complete file name you may name the transferred file anything you want.

Uploading files from your local computer

BOOL success = [session uploadFile:@"~/my-local-file.txt" to:@"/var/www/"];

Downloading files from a server

BOOL success = [session downloadFile:@"/var/www/my-remote-file.txt" to:@"~/"];

License

Copyright (c) 2012 Nine Muses AB

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

NMSSH is an Objective-C wrapper for libssh2, with a sweet API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 50.9%
  • Objective-C 48.7%
  • Other 0.4%