View Code? Open in Web Editor
NEW
This project forked from qoomon/aws-ssm-ec2-proxy-command
AWS SSM SSH Proxy Command
aws-ssm-ec2-proxy-command's Introduction
aws-ssm-ec2-proxy-command
- Local Setup
- Ensure Your IAM Permissions
- IAM Policy Example
ssm:StartSession
for DocumentName: AWS-StartSSHSession
and Target Instance
ssm:SendCommand
for DocumentName: AWS-RunShellScript
and Target Instance
- Target Instance Setup
- Ensure SSM Permissions fo Target Instance Profile
- Ensure SSM Agent is installed (preinstalled on all AWS Linux AMIs already)
Install SSH Proxy Command
- Move proxy command script aws-ssm-ec2-proxy-command.sh to
~/.ssh/aws-ssm-ec2-proxy-command.sh
- Ensure it is executable (
chmod +x ~/.ssh/aws-ssm-ec2-proxy-command.sh
)
- Add ssh config entry for aws ec2 instances to your
~/.ssh/config
. Adjust key file path if needed.
host i-* mi-*
IdentityFile ~/.ssh/id_rsa
ProxyCommand ~/.ssh/aws-ssm-ec2-proxy-command.sh %h %r %p ~/.ssh/id_rsa.pub
StrictHostKeyChecking no
ssh <INSTACEC_USER>@<INSTANCE_ID>
- Ensure AWS CLI environemnt variables are set properly
- e.g.
AWS_PROFILE='default' ssh ec2-user@i-xxxxxxxxxxxxxxxx
- If default region does not match instance region you need to provide it like this
AWS_PROFILE='default' ssh <INSTACEC_USER>@<INSTANCE_ID>--<INSTANCE_REGION>
Alternative Implementation with ec2-instance-connect
aws-ssm-ec2-proxy-command's People
Contributors
Watchers