Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ssh tunnel to zmNinja authentication methods. #1103

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

autonomous1
Copy link

@autonomous1 autonomous1 commented Feb 2, 2023

This pull request enables zmNinja to establish a connection to a ZM server via a reverse ssh tunnel with local forwarding ports to http, https, ZM event server, MQTT and so on. In the zmNinja settings page, a new option called "use ssh tunnel" has been added for specifying parameters to use to setup the tunnel. The parameters are for remote username, password, host and port, a list of forwarded ports and an option to include a ngrok api key so that the ngrok host and port can be obtained. Private keys are stored in the system keychain.

The ssh client runs in the main process and uses the electron IPC interface to exchange messages with the render process for security purposes. In addition, the list of remote ports that can be opened in the system port range are limited to a list of ports specified in the main process.

The code to setup a ssh tunnel proxy is from a npm package called ssh_tunnel_proxy. To test the tunnel configuration there is a command line interface that allows specification of tunnel parameters from a config file and establishes a tunnel with these parameters. When running the cli interface the desktop version of zmNinja can connect to the remote ports, provided that the keys and other parameters are configured correctly for the remote host.

Currently I am grappling with finding the best method of including external node modules as part of the electronjs main process. I have only tested the desktop version of this fork and it works well. I have also tested ssh tunneling on android under termux and that works as well. Once the bundling of external node modules has been resolved this fork should run on all platforms. Another item is to verify that connecting to multiple servers works.

There are a few other changes in the fork, namely upgrading to the latest version of electron and fixing a few minor issues with debug logging.

I'm currently researching install and build procedures for including external modules and native node modules such as keytar.

As a workaround to include dependent modules in a distribution build:
cd node_modules/ssh_tunnel_proxy
npm i

After this the desktop version can be built:
npm run dist-lin

To run in debug mode without having to build zmNinja distributions, I use:
./node_modules/electron/dist/electron --inspect electron_js/main.js

And for some unknown reason, after building an error occurs where a native node module cannot be loaded. If an error is thrown when running the unbuilt package, where keytar.node is not found do:
npm remove ssh_tunnel_proxy
npm i ssh_tunnel_proxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant