Skip to content

M41doror/aws-ssm-ec2-proxy-command

Repository files navigation

aws-ssm-ec2-proxy-command

Prerequisits

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)
Setup SSH Config
  • 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

Open SSH Connection

  • 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

About

AWS SSM EC2 SSH Proxy Command

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%