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

Rivindu Wanniachchi
Sep 6, 2018 · 2 min read

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

  1. 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)
  2. The ssh configuration Description: The host you want to use as ssh-tunnel server. Properties: ** host ** port (22) ** username ** …
  3. 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!

Rivindu Wanniachchi

Written by

99x Technology, University of Moratuwa

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade