Skip to content
Stuff I'm Up To
Go back
AWS SSH using SSM

AWS SSH using SSM

Updated:

You can access a closed off AWS EC2 instance using SSH by using SSM as a proxy. This means no ports need be exposed from your EC2 at all.

Configure the AWS Client

aws configure

Specify your user access key, secret and region.

Connect to the EC2 instance

aws ssm start-session --target [instance_id]

Connect to SSH through an SSM port forward

aws ssm start-session --target [instance_id] \
  --document-name AWS-StartPortForwardingSession \
  --parameters '{"portNumber":["22"], "localPortNumber":["2222"]}'

ssh -p 2222 -i ~/.ssh/id_rsa root@localhost

References

https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-enable-ssh-connections.html

https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html#sessions-start-ssh


Share this post:

Previous Post
AWS S3 Bucket Service
Next Post
Caddy in Production