a library that enables React Native apps to execute commands over SSH

Peter Valdez 5462719da9 v1.0.1 2 years ago
android 4366030463 Initial commit with SSH working on Android 2 years ago
ios 3afbc5a083 Fix a bug where trailing newlines would have iOS returning an extra line 2 years ago
.gitignore 216b5ba509 Make mock iOS SSH method 2 years ago
Podfile.example bb755d238d Update the README 2 years ago
README.md efda6f5b3a Clarify the README's example 2 years ago
index.js 4366030463 Initial commit with SSH working on Android 2 years ago
package.json 5462719da9 v1.0.1 2 years ago

README.md

react-native-ssh npm version

A library that allows a React Native app to run commands over SSH.

Usage

This library provides a single method: SSH.execute. Given SSH credentials and a command, a promise is returned. This promise resolves to the command's output as an array of strings.

import SSH from 'react-native-ssh';

config = {user: 'bob', host: 'example.com', password: 'p4$$w0rd'};
command = 'ls -l ~';

SSH.execute(config, command).then(
  result => console.log(result),
  error =>  console.log('Error:', error)
);

// A successful run would output:
// ['file1.txt', 'server.py', 'script.sh']

Installation

Android

  • npm install react-native-ssh --save
  • react-native link react-native-ssh

iOS

  • npm install react-native-ssh --save
  • react-native link react-native-ssh
  • Add pod 'NMSSH', '~> 2.2.5' to your Podfile and install. If you don't have a Podfile:
    • cd ios
    • pod init
    • Edit the newly created Podfile to look like this example
    • pod install
  • Make the Pod headers accessible to react-native-ssh (instructions based on XCode 8.1):
    • Open ios/hooks.xcworkspace in XCode
    • Click on hooks > Libraries > RNSSH.xcodeproj in the Project Navigator
    • Click on RNSSH under Targets
    • Go to Build Settings
    • Add $(SRCROOT)/../../../ios/Pods/Headers/Public to Header Search Paths and make it recursive