Open ghost opened 5 years ago
Hard coded on my end for now, in EC2InstanceConnectCommand.py, in the _get_target function, change:
if instance_bundle.get('host_info', None): target = "{0}@{1}".format(instance_bundle['username'], instance_bundle['host_info'])
To:
if instance_bundle.get('host_info', None): target = "{0}@{1}".format(instance_bundle['username'], instance_bundle['instance_id'])
Thank you for the feature and pull request. We have discussed this the SSM team and are open to accepting the option. We will review and test this once we have a chance and will merge it into the CLI if all goes well.
Could we use ssh config file or at least being able to script SSH via SSM tunneling similar to this:
Host *
TCPKeepAlive yes
ServerAliveInterval 30
ConnectTimeout 10
host i-*.* mi-*.*
ProxyCommand bash -c "aws ssm start-session --target $(echo %h|cut -d'.' -f1) --region $(echo %h|/usr/bin/cut -d'.' -f2) --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
User ec2-user
host i-* mi-*
ProxyCommand bash -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
User ec2-user
Then you would just:
mssh ec2-user@i-0ded1d8c2282ee39e.ap-southeast-2
or
mssh i-0ded1d8c2282ee39e.ap-southeast-2
I've written an implementation can work entirely inside of ssh_config and does not need a wrapper
https://gist.github.com/Maks3w/de72b0160d5e6af958adc42eab014624
Provide a flag so that if you do 'mssh instance_id' that the eventual ssh command executed continues to use the instance_id and not the ip address of the instance. This should allow for seamless integration with Session Manager ssh tunneling.