Connect to EC-2 instance using SSH, SSM and VS Code. No public access or ports required
Arijus Gilbrantas
Posted on December 22, 2023
How to
- Install SSH extension to vs code.
- Import your public Yubikey cert to AWS Key pairs and name it Yubi.
- Deploy EC2 with Yubi key attached.
- Add the following to
~/.ssh/config
:
# This is needed for VS code to know how to connect
Host i-0b377eeb467ae2f92
HostName i-0b377eeb467ae2f92
# SSH over Session Manager implementation. Change profile as you wish.
Host i-* mi-*
User ec2-user
ProxyCommand sh -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --profile <<my_aws_profile>> --region eu-central-1"
- CMD + Shift + P → Remote-SSH: Connect Current Window to Host…
- Select your host and connect.
- You can open folder too, for file editing/transfer.
- Celebrate!
💖 💪 🙅 🚩
Arijus Gilbrantas
Posted on December 22, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
aws Connect to EC-2 instance using SSH, SSM and VS Code. No public access or ports required
December 22, 2023