No description
Find a file
2016-04-08 10:48:25 -06:00
src adds auto port generation and port checking 2016-04-08 10:48:25 -06:00
.babelrc initial commit 2016-04-07 19:22:13 -06:00
.gitignore adds readme 2016-04-07 19:56:14 -06:00
demo.js adds auto port generation and port checking 2016-04-08 10:48:25 -06:00
index.js adds auto port generation and port checking 2016-04-08 10:48:25 -06:00
package.json adds auto port generation and port checking 2016-04-08 10:48:25 -06:00
README.md adds readme 2016-04-07 19:56:14 -06:00

autossh

Persistent SSH tunnels

Install

Using npm

npm i -S autossh

Usage

To Start

const autossh = require('autossh');

autossh({
  host: '111.22.333.444',
  username: 'root',
  localPort: 64444,
  remotePort: 5432
})
.on('error', err => {
  console.error('ERROR: ', err);
})
.on('init', () => {
  console.log('connected. Ready to do other stuff.');
});

...is equivalent to...

ssh -NL 64444:localhost:5432 root@111.22.333.444

To Kill

The autossh process will automatically die if the node process is closed, but you can manually kill the process using kill.

Example

const myAutossh = autossh({
  host: '111.22.333.444',
  username: 'root',
  localPort: 64444,
  remotePort: 5432
})
.on('error', err => {
  console.error('ERROR: ', err);
})
.on('init', () => {
  console.log('connected. Ready to do other stuff.');
});

myAutossh.kill();