Skip to content

Instantly share code, notes, and snippets.

@dex4er
Created June 15, 2025 08:47
Show Gist options
  • Save dex4er/c01f40eb79c26101a96bf6767dd120a5 to your computer and use it in GitHub Desktop.
Save dex4er/c01f40eb79c26101a96bf6767dd120a5 to your computer and use it in GitHub Desktop.
ssh ssm
Host i-* mi-*
User root
ProxyCommand sh -c "instance=\$(echo %h | cut -d. -f1); profile=\$(echo %h | cut -d. -f2); profile=\${profile:-\$AWS_PROFILE}; region=\$(echo %h | cut -d. -f3); region=\${region:-\${AWS_REGION:-\$(aws configure get region --profile \${profile:-\$AWS_PROFILE})}}; aws ec2-instance-connect send-ssh-public-key --profile \${profile} --region \${region} --instance-id \${instance} --instance-os-user %r --ssh-public-key file://\${HOME}/.ssh/id_rsa.pub; aws ssm start-session --profile \${profile} --region \${region} --target \${instance} --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
ServerAliveInterval 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment