I am currently living somewhere without Wi-Fi. When I need to go online, I’ll usually use my phone as a hotspot, or just drive to the local coffee spot and use their public Wi-Fi through a vpn. I’ve also recently gotten back into programming, and have started developing an app that requires a backend hosted on EC2. However, I only want to let traffic in coming from my computer. Is there a way to configure the network settings to do this, given the variable network connections I’ll be making from my computer?
Edit: Optionally, I’d also be fine with some kind of username and password requirement to connect to the backend.
On the security group you can assign to your ec2 there is an option for “my ip” seems like you should still only allow what you need though I.e. ssh etc.
Use SSM Session Manager, this doesn’t require any additional network setup and you don’t even have to allow SSH port on security group. This also uses username and password both on CLI and console, you just need SSM session manager plugin for CLI.
Locking down by network restriction sounds like a good idea until something fails. The best way is to use public-private key connection to eliminated password access. I use tinc for that. The method used in this article should work on most Linux.
That isn’t bad advice but, let’s suppose that you actually want network access back to your box without going through a third party broker. 2 suggestions:
Set up a security group for your EC2 instance. You can manually update the rules to permit traffic from your current location via the AWS API’s - either via the console (web browser) or a script, like this guy or this guy
Use AWS client VPN. The advantage of this is that it’s first party. The downside is that it won’t be the cheapest available option.
I’m not sure if you’re saying SSM is a third-party service, it isn’t.Or are you saying direct SSH access is better than through SSM? In that case, you can use SSM to SSH directly to the box.
I use these lines in my .ssh/config to access my boxes without allowing any access from the public network:
Long before zero tier and wanting to avoid the cost of a vpn, I used something similar to the below.
Squiff mentioned this, and for me it worked a treat.
SSM is a first party tool as it is made available by AWS. However, it is a third party tool for most software that you would want to interact with your host using. It’s relatively easy to get an EC2 instance with SSM access. Say for instance, you want to do mobile development and you have your back end on EC2. You’re not going to have much luck getting an SSM client going on a mobile phone. Yes, you can tunnel most traffic over SSH and if your SSH is going over SSM then your applications and tooling can be naive for that protocol. I’m aware also of tools like sshuttle. It can still more of a pain to set up depending on your tool set than a VPN or simply public access.