Socket
Socket
Sign inDemoInstall

node-ssh

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ssh

SS2 with Promises


Version published
Weekly downloads
109K
decreased by-0.15%
Maintainers
1
Weekly downloads
 
Created
Source

Node-SSH - SSH2 with Promises

Node-SSH is an extremely lightweight Promise wrapper for ssh2, Period.

Example
var node_ssh, ssh;

node_ssh = require('node-ssh');

ssh = new node_ssh({
  host: 'localhost',
  username: 'steel',
  privateKey: '/home/steel/.ssh/id_rsa'
});

ssh.connect().then(function() {
  // Source, Target
  ssh.put('/home/steel/Lab/LocalSource', '/home/steel/Lab/RemoteTarget').then(function() {
    console.log("The Directory thing is done");
  }, function(error) {
    console.log("Something's wrong");
    console.log(error);
  });
  // Array<Shape('Local' => string, 'Remote' => string)>
  ssh.putMulti([{'Local': '/home/steel/Lab/LocalSource', 'Remote': '/home/steel/Lab/RemoteTarget'}]).then(function() {
    console.log("The Directory thing is done");
  }, function(error) {
    console.log("Something's wrong");
    console.log(error);
  });
  // Source, Target
  ssh.get('/home/steel/Lab/RemoteSource', '/home/steel/Lab/LocalTarget').then(function(Contents) {
    console.log("The File's source was: "+Contents);
  }, function(error) {
    console.log("Something's wrong");
    console.log(error);
  });
  // Command
  ssh.exec('hh_client --json',{cwd:'/var/www'}).then(function(result) {
    console.log('STDOUT: ' + result.stdout);
    console.log('STDERR: ' + result.stderr);
  });
});
API
type PutInfo = shape(LocalPath => string, RemotePath => string)
class SSH{
  constructor(SSH2Configuration)
  connect():Promise<void>
  mkdir(Path:String):Promise<void>
  exec(Command:String, {cwd:String}):Promise<Object{stderr:String, stdout: String}>
  put(LocalPath:String, RemotePath:String, ?SFTP: SSH2SFTP, ?Retry:Boolean = true):Promise<void>
  putMulti(Files:array<PutInfo>, ?SFTP: SSH2SFTP):Promise<void>
  get(RemoteFile:String, ?LocalFile:String, ?SFTP: SSH2SFTP):Promise<?string>
  requestSFTP():Promise<SSH2SFTP>
  end():void
}

License

This project is licensed under the terms of MIT license. See the LICENSE file for more info.

Keywords

FAQs

Package last updated on 09 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc