Cameronsplaze / AWS-ContainerManager

CDK Architecture to spin up containers when you connect, and back down afterwards automatically.
2 stars 0 forks source link

[Optimization] Use SSM Session Manager instead of SSH directly #2

Open Cameronsplaze opened 1 month ago

Cameronsplaze commented 1 month ago

Is your feature request related to a problem? Please describe. Security improvement, this would let us close port 22 on the ec2 instance. Also since users have to create ~/.aws/credential's to deploy already, this should let them ssh out of the box, without having to grab the ssh key from the console.

Describe the solution you'd like Get the docs here to work.

Describe alternatives you've considered SSH directly is the main alternative. There's no fail2ban, but there is faillock to help stop attacks. SSM is ideal, but this isn't an "awful" alternative.

Additional context The main part I'm stuck on is the ssm command itself requires you to set --target=<InstanceId>. We don't know what it is (and it changes every startup), so I'd need a bash or python script to use route53 to figure out the instance IP, then use a aws ec2 describe-instances to get the instance details based on said IP, then pass that to ssm. That's too much to put in a ssh config (without being unreadable), so we'd have to have a script in the root of this project, and maybe have them create a softlink from ~/.ssh/... to said script. (That way users get updates/bug fixes if we have to edit the script later).

If we can get this working, it'd let us block 22 on the security group completely! We just want to make sure SFTP with FileZilla (or something) works first.


If this isn't possible and we need to keep SSH, then do some work to support it more:

I'll open a new issue if it's not, just keeping the bullets here to not forget anything. I won't want to improve ssh support, only to delete it if this issue is possible, so this issue is technically a blocker in a way.