https://github.com/azer/remotely
Run given command remotely via SSH
https://github.com/azer/remotely
Last synced: 11 months ago
JSON representation
Run given command remotely via SSH
- Host: GitHub
- URL: https://github.com/azer/remotely
- Owner: azer
- Created: 2014-03-11T05:59:50.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-13T02:01:13.000Z (over 12 years ago)
- Last Synced: 2024-04-15T03:09:39.928Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 145 KB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## remotely
Run given command remotely via SSH
```js
remotely = require('remotely')
remotely('user@hostname', 'echo $HOME').stdout.pipe(process.stdout)
// => /home/username
```
## Install
```bash
$ npm install remotely
```
## Usage
### Callbacks
If callbacks work better than piping in your case, pass a function as last parameter:
```js
remotely = require('remotely')
remotely('user@hostname', 'echo $HOME', function (error, stdout, stderr) {
stdout
// => /home/username
})
```
### Streams
You can pipe commands to call:
```js
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:
```js
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`:
```js
remotely('user@host', 'pwd', { options: { UserKnownHostsFile: '/dev/null' } }).stdout.pipe(process.stdout)
```
### SSH Identity
You can specify a custom identity file:
```js
remotely('user@host', 'pwd', { identity: '/home/azer/ssh-foo/.id_rsa' }).stdout.pipe(process.stdout)
```
## Debugging
```bash
DEBUG=remotely:* node yourscript.js
```
## Testing
Test module requires a hostname as third parameter.
```bash
$ node test.js user@hostname
```