Skip to content

Instantly share code, notes, and snippets.

@nicornk
Created February 12, 2025 11:23
Show Gist options
  • Save nicornk/5d2c0cd02179f9b46cc7df459af0c16c to your computer and use it in GitHub Desktop.
Save nicornk/5d2c0cd02179f9b46cc7df459af0c16c to your computer and use it in GitHub Desktop.
AWS SSM SSH Config
host i-*
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
ServerAliveInterval 120
User ec2-user
ProxyCommand sh -c "aws ec2 start-instances --instance-ids %h ; aws ec2 wait instance-running --instance-ids %h ; aws ec2-instance-connect send-ssh-public-key --instance-id %h --instance-os-user %r --ssh-public-key 'file://~/.ssh/id_rsa.pub' --availability-zone $(aws ec2 describe-instances --instance-ids %h --query 'Reservations[0].Instances[0].Placement.AvailabilityZone') ; aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment