DEV Community

4 1

Establish an SSH connection using AWS EC2 instance

Introduction

  • Before starting, see my previous post from here
  • SSH tunnels allow you to connect to ports on a remote server through the encrypted SSH channel.
  • This allows you to securely connect to ports on the remote server that you otherwise wouldn't be able to because of system firewall, or security group rules.
  • In this post, you will establish an SSH connection with a tunnel from port 8000 to port 8888 on the remote server.
  • This tunnel will allow you to connect from instance public IP to the Jupyter notebook server.

Establish an SSH connection

Step 1

Connect to your EC2 Instance:

Image description

Image description

Step 2

Enter the following command and press Enter:

ssh -i key.pem ubuntu@localhost -fN -L 0.0.0.0:8000:127.0.0.1:8888
Enter fullscreen mode Exit fullscreen mode

The -fN creates the tunnel in the background and the 0.0.0.0 tells it to listen on all interfaces instead of only 127.0.0.1/localhost so you can connect from the public IP

Step 3

Enter yes to establish the connection:

Image description

Now, you connected to the remote server and established an SSH tunnel to forward a port on the remote server.



GitHub
LinkedIn
Facebook
Medium

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay