Socket
Socket
Sign inDemoInstall

node-ssh

Package Overview
Dependencies
9
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-ssh

SS2 with Promises


Version published
Weekly downloads
101K
increased by4.21%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Node-SSH - SSH2 with Promises

Sorry, but I have no time to write the documentation, but this example should give you a clue on how it works.

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);
  });
});

Keywords

FAQs

Last updated on 07 Feb 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc