Socket
Book a DemoInstallSign in
Socket

remotely

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remotely

Run given command remotely via SSH

npmnpm
Version
1.1.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

remotely

Run given command remotely via SSH

remotely = require('remotely')

remotely('user@hostname', 'echo $HOME').stdout.pipe(process.stdout)
// => /home/username

Install

$ npm install remotely

Usage

Callbacks

If callbacks work better than piping in your case, pass a function as last parameter:

remotely = require('remotely')

remotely('user@hostname', 'echo $HOME', function (error, stdout, stderr) {

  stdout
  // => /home/username

})

Streams

You can pipe commands to call:

remotely = require('remotely')('azer.io')

remotely.stdout.pipe(process.stdout)

process.stdin.resume()
process.stdin.pipe(remotely.stdin)

See example.js for a working example

Child Process options

Remotely has a similar interface to child_process.exec. You can pass child options as third parameter:

remotely('user@hostname', 'echo $HOME', { timeout: 2000 }).stdout.pipe(process.stdout)

See test.js and example.js for more information.

SSH Options

To specify SSH options like UserKnownHostsFile:

remotely('user@host', 'pwd', { options: { UserKnownHostsFile: '/dev/null' } }).pipe(process.stdout)

SSH Identity

You can specify a custom identity file:

remotely('user@host', 'pwd', { identity: '/home/azer/ssh-foo/.id_rsa' }).pipe(process.stdout)

Debugging

DEBUG=remotely:* node yourscript.js

Testing

Test module requires a hostname as third parameter.

$ node test.js user@hostname

Keywords

ssh

FAQs

Package last updated on 13 Mar 2014

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