How to connect to an EC2 Private Instance via SSM Port Forwarding !

AWS Cli installation in Windows and Linux

1. https://awscli.amazonaws.com/AWSCLIV2.msi — download this in Windows machine

2. curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o “awscliv2.zip”

unzip awscliv2.zip

1. sudo ./aws/install

Links from AWS for the above — Installing or updating the latest version of the AWS CLI — AWS Command Line Interface (amazon.com)

AWS Session Manager Installation in Windows and Linux

1. https://s3.amazonaws.com/session-manager-downloads/plugin/latest/windows/SessionManagerPluginSetup.exe — — copy this URL and paste it in browser and download it/run it — For windows machine 64 bit

2. curl “https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_64bit/session-manager-plugin.rpm" -o “session-manager-plugin.rpm”

3. sudo yum install -y session-manager-plugin.rpm — — run this and above command in Linux terminal

Policies to be applied for a IAM user to access the private EC2 instance via session manager from your local machine

1. Configure IAM user in your laptop using

2. $ aws configure

3. AWS Access Key ID [None]: accesskey to be copy and pasted here

4. AWS Secret Access Key [None]: secretkey to be copy and pasted here

5. Default region name [None]: the region of your EC2 machine to be entered here for example for Mumbai ap-south-1

6. Default output format [None]: click on Enter

Attach this role to your EC2 instance

Permission of IAM user to access Session Manager via Laptop Cli :

Command to execute from your laptop to access Windows Private EC2 instance –

aws ssm start-session — target (copy paste your instance id here) — document-name AWS-StartPortForwardingSession — parameters “portNumber”=[“3389”],”localPortNumber”=[“9090”]

Port 9090,3389 must be allowed in security group of EC2 instance

For more information pls check –

SSM Port Forwarding — Private Windows RDP Access — YouTube

New — Port Forwarding Using AWS System Manager Session Manager | AWS News Blog (amazon.com)

To connect to your private EC2 instance follow the below from your laptop

--

--

--

I am an AWS Cloud-Presales consultant, I have 10–11 years of Infra work experience. I am passionate about Cloud computing. Blogging is my passion!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Starting My InfoSec Journey

Fist Pump Baby Meme — Caption: Wannabe Hacker Skills Confirmed

One Law, Six Hurdles: Congress’s First Attempt to Regulate Speech Amplification in PADAA

The Digital Civilization

DeFiat Upgraded: DFTPv2 and Governance updates

Decentralized Identity (DID) — Part I

Apache Issues 3rd Patch to Fix New High-Severity Log4j Vulnerability

How Does The Internet Work?

Using the 4GEE Home Router as a secondary WAN for failover with OpenWrt and mwan3

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aravind KumarTS

Aravind KumarTS

I am an AWS Cloud-Presales consultant, I have 10–11 years of Infra work experience. I am passionate about Cloud computing. Blogging is my passion!

More from Medium

TryHackMe: How the Web Works — How Websites Work a Walkthrough

BookMyShow- (MERN Stack)

MERN Stack

Express.js