Socket
Socket
Sign inDemoInstall

node-ssh

Package Overview
Dependencies
11
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
100K
increased by7.66%
Maintainers
1
Install size
0.994 MB
Created
Weekly downloads
 

Changelog

Source

2.0.4

  • Fix stdin support in .exec and .execCommand

Readme

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

ssh.connect({
  host: 'localhost',
  username: 'steel',
  privateKey: '/home/steel/.ssh/id_rsa'
}).then(function() {
  // Source, Target
  ssh.put('/home/steel/Lab/LocalSource', '/home/steel/Lab/RemoteTarget').then(function() {
    console.log("The File 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 File 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 contents were successfully downloaded");
  }, function(error) {
    console.log("Something's wrong");
    console.log(error);
  });
  // Command
  ssh.execCommand('hh_client --json', {cwd:'/var/www', stream: 'both'}).then(function(result) {
    console.log('STDOUT: ' + result.stdout);
    console.log('STDERR: ' + result.stderr);
  });
});
API
class SSH{
  constructor()
  connect(SSH2Configuration): Promise<void>
  mkdir(Path:String): Promise<string>
  exec(command: String, args: Array<string>, options: Object{cwd: String, stdin: String, stream: enum{'stdout', 'stderr', 'both'}}): Promise
  execCommand(command: String, options: Object{cwd: String, stdin: String, stream: enum{'stdout', 'stderr', 'both'}}): Promise
  put(localPath: String, remotePath: String, ?SFTP: SSH2SFTP, ?Retry:Boolean = true): Promise<void>
  putMulti(Files:array<Object{Local: String, Remote: String}>, ?SFTP: SSH2SFTP): Promise<void>
  get(remoteFile: String, localFile: String, ?SFTP: SSH2SFTP): Promise<?string>
  requestSFTP(): Promise<SSH2SFTP>
  requestShell(): Promise<SSH2Shell>
  end():void
}

License

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

Keywords

FAQs

Last updated on 28 Sep 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