Creating a SSH Tunnel to an AWS ec2 instance using a NodeJS App — Part 2 : Configuration for SSH Connections

Hello guys! , in the last episode we looked at how we set up an S3 bucket in AWS and how to retrieve data from it to an NodeJS application.
In this episode we’ll look at the configuration set up needed to create a SSH tunnel to the ec2 instance as we intend to.
For this, we’ll be using the “tunnel-ssh” library
github.com/agebrock/tunnel-ssh
Understanding the configuration
- A local server listening for connections to forward via ssh Description: This is where you bind your interface. Properties: ** localHost (default is ‘127.0.0.1’) ** localPort (default is dstPort)
- The ssh configuration Description: The host you want to use as ssh-tunnel server. Properties: ** host ** port (22) ** username ** …
- The destination host configuration (based on the ssh host) Imagine you just connected to The host you want to connect to. (via host:port) now that server connects requires a target to tunnel to. Properties: ** dstHost (localhost) ** dstPort
Uploading the configuration file to S3 bucket
Next, we can upload our own configurations to the S3 bucket in the JSON format so it’s retrievable from our application itself.
Parsing the retrieved JSON objects into a module
As we have seen in the first episode , we retrieve the S3 hosted data file via the “index.js” file . Now we will parse our JSON objects.
config-data.js
That’s it for this episode guys! You can leave doubts or questions that you could have in the comments area bellow and I will complement the post.
In the next episode how we can connect to the servers!
Happy coding!