ComputeOnCloud

← Blog

Wrapper over AWS Session Manager to SSH using Public/Private IP

January 5, 2023

Two recurring pains with SSH onto EC2: managing keys across a growing fleet of servers, and reaching instances that don’t have a public IP without standing up a bastion host.

AWS Session Manager solves both, natively — no keys to manage, no bastion needed for private instances. Its one rough edge: the standard CLI workflow wants an instance ID, not an IP address, which breaks the muscle memory of a team used to ssh <ip>.

The wrapper

We built a small wrapper around the AWS CLI that lets you start a Session Manager session using either a public or private IP address — the lookup to an instance ID happens behind the scenes.

Code: github.com/MrHassanMurtaza/ec2-ssh

It gives you Session Manager’s security and operational benefits (centralized credential management, no bastion host for private instances) with the IP-based workflow teams already know.