aws / aws-ec2-instance-connect-cli

This is an all-in-one client for EC2 Instance Connect that handles key brokerage and establishing connection to EC2 Instances through an interface near-identical to standard system ssh, sftp, and other utilities.
Apache License 2.0
160 stars 42 forks source link

Support using private ip of an instance without passing the private ip as an argument #16

Open colwynmyself opened 4 years ago

colwynmyself commented 4 years ago

Right now there are two ways to SSH to the private ip of an instance rather than the public ip:

  1. Don't have a public ip
  2. Pass in the private ip of the instance with a -t <instance-id> argument attached

It would be great if we could pass in an argument like --private to mssh that would make the resulting ssh command use the private ip without having to go fetch the private ip of the instance.

I threw together a quick branch on a fork of the project that supports this, but it doesn't include any tests. https://github.com/aws/aws-ec2-instance-connect-cli/compare/master...colwynmyself:support_private_flag

If you'd like I can look into tidying that up a bit or I could even just open a PR against this project if y'all would like.

scampuza commented 3 years ago

@colwynmyself Were you able to connect to the EC2 instance using the Private IP ?

colwynmyself commented 3 years ago

@scampuza When I initially created this PR, yeah. I haven't tested it in over a year but I imagine it would still work since the changes are so simple.

virmantas-simplex commented 3 years ago

@colwynmyself Were you able to connect to the EC2 instance using the Private IP ?

I have instance with Public address (used only for HTTPS connections from the Internet) and Private address (used form ssh into this instance from bastion). When I try to mssh in into this instance from bastion I see mssh is trying to establish connection with external IP.

gwittel commented 2 years ago

Just tested this patch with a fresh install and it works fine. It would be really helpful to have this baked in.