Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tunnel-exec

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tunnel-exec

Opens an ssh tunnel and then executes some code while it's open

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

tunnel-exec

Opens an ssh connection, then a local tunnel to another host from there. After that, you can execute any action on the tunnel.

var tunnelExec = require('tunnel-exec')

tunnelExec(
    {
        remoteHost: 'example.com',
        remotePort: '22',

        targetHost: 'host2.example.com',
        targetPort: '1234',

        localPort: 9009,

        user: 'myUser',
        identityFile: '~/.ssh/id_rsa.pub',

        timeout: 30000
    },
    function(err, tunnel) {
      if(err) {
        console.log(err)
        process.exit(1)
      }

      // Do your stuff here

      // Close the tunnel
      tunnel.done()
    }
)

The previous options calls the ssh command as follows:

ssh -p 22 -L 9009:host2.example.com:1234 -i ~/.ssh/id_rsa.pub myUser@example.com

If the connection is not established within 30 seconds, the process stops with an error.

NOTE:

You should always call tunnel.done() when your function is finished. That way, the tunnel is closed and the process finished.

License

MIT

Keywords

FAQs

Package last updated on 18 Sep 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc