Both things have been introduced recently, and let you access even private ec2 instances
- Without VPN
- No open SSH port
- Authentication / Authorization is fully delegated to IAM
# Assumes valid AWS Credentials in ENV
# Important. Always set the username
ssh ec2-user@i-002afb820244e392f
What this will do (through the aws-proxy
script below):
- Generate a single use ssh key
- Push the generated publich key to AWS for the given user of the provided ec2 instance id
- Create a tunnel through Session Manager
- Establish an SSH session
The host has to be configured to run:
- SSM Agent
- ec2-instance-connect
Locally, you'll have to have a recent version of the AWS cli and the SSM plugin
@Maks3w the last line doesn't seem to work (running on macOS X). Key files are still there. Any ideas? I am admittedly very new to SSH config. There is no output to indicate that it didn't work; in fact there's no output at all even with
-v
.EDIT: so if you call
ssh
the files are cleaned up. If you callscp
the files are not cleaned up. Withscp
it appears the config stops executing...still digging.