You could try using Tailscale. It's a wireguard based mesh VPN. Just set it up on your device, your server, and you're good to go. You can just only allow SSH over Tailscale, without worrying about anybody else trying to get in. Other alternatives include ZeroTier and Nebula afaik, but I've never tried either. (Still use SSH keys regardless though.)
Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
21–30 of 48 posts
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#22Even if you don’t have a static IP, you can probably restrict to a /24 subnet or maybe /16. Additionally, you can ensure password access is disabled and use ssh keys along with 2FA.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#23Disallow password logins, change ssh port, change/hide sshd identity information or configure port knocking.
Is changing SSH port really necessary? If your SSH is vulnerable, attackers will find the Port for it.
Add ipv6 into the mix and it's straight up infeasible to scan for even ONE port on every host!
Port knocking + key auth + non-default port is pretty damn good security, even against zero days in SSH.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#24Earlier quoted context omitted.
The same question applies to oracle VPS: how to allow only few IPs? A compromise of oracle VPS and attacking AWS VPS is same as attacking AWS VPS from internet. If oracle VPS is not compromised, neither will be AWS. Don’t see the point in this case.
The advantage is that you only need to harden one instance. The others are safe as they're basically in an "internal" network (firewall blocks all other IPs). With that bastion host, you'd do anything to make it as secure as possible (fail2ban or the like, authkey, block countries you won't access from, etc). For small projects, it's also reasonable to check logs from one host, but not to do so for 10 hosts.
Bastion makes sense if it’s locked down more than destination. This doesn’t apply if there is only one destination and one public service (SSH).
I suggest using AWS AMS or putting it behind vpn.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#25Earlier quoted context omitted.
Just curious but what would adding a /24 or /16 do if we're still allowing 0.0.0.0?
You would set it based on the range your ISP tends to assign you, and remove 0.0.0.0 for the ssh port.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#26Earlier quoted context omitted.
The advantage is that you only need to harden one instance. The others are safe as they're basically in an "internal" network (firewall blocks all other IPs). With that bastion host, you'd do anything to make it as secure as possible (fail2ban or the like, authkey, block countries you won't access from, etc). For small projects, it's also reasonable to check logs from one host, but not to do so for 10 hosts.
Sorry I am missing your point. That makes sense if first VPS is serving multiple ssh servers; so you harden one instance. In this case, the person has only one instance. Instead of hardening oracle VPs, they could harden aws instance. Bastion makes sense if it’s locked down more than destination. This doesn’t apply if there is only one destination and one public service (SSH). I suggest using AWS AMS or putting it be…
So back to the bastion. You have the bastion open to all IPs for port 22 because you want to be able to connect to it from anywhere. Yes you also of course lock it down and use best practice sshd config measures. But you only have ssh running and you use keys with passphrase for your outbound ssh connections for increased security. You keep it updated.
Your bastion will not be as locked down as your AWS instance though because it won’t have that AWS security in front of it, but you’re not concerned that much about your bastion, because it only has ssh listening, and you’ve disabled root ssh and password login, you keep it regularly updated, and the only thing you ever do with it is ssh to it and then ssh again to your important endpoints using a key WITH a passphrase.
Your AWS instance is your primary concern and is the important thing that you care about the most here. So you put the most protection in front of that in front of key services. Like OP said, ssh to the AWS instance sort of becomes “internal” so to speak, as you can only come in from the bastion with a key and passphrase.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#27Earlier quoted context omitted.
Sorry I am missing your point. That makes sense if first VPS is serving multiple ssh servers; so you harden one instance. In this case, the person has only one instance. Instead of hardening oracle VPs, they could harden aws instance. Bastion makes sense if it’s locked down more than destination. This doesn’t apply if there is only one destination and one public service (SSH). I suggest using AWS AMS or putting it be…
If his AWS instance is running internet facing applications and services, then it makes sense to have the AWS firewall lock down port 22 to a single IP or two (eg your bastions), and also have that AWS firewall only allow all access to those specific internet facing ports for any relevant applications. Yes you can and should also harden at the OS level. But it’s smart to utilize AWS’ security as well as much as possi…
Even better, no open port anywhere is actually needed.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#28If you don't allow password logins so ssh only accepts public/private keypair authentication I think you have a secure setup. Limiting the IPs allowed to connect in the firewall will block the bots that probe port 22 and brute-force attacks, but those aren't going to succeed anyway. As far as I know it's not possible to brute force or otherwise hack ssh with ssl keypair authentication directly. An attacker would need…
Theoretically, a vulnerability in SSH could expose you, but I think those are quite rare. The bigger risk of keeping the server exposed is probably that some application opens another port. But that won't happen on Port 22, so that one could stay open to all.
Firewall rules in front of ssh are a good idea but I don’t think that adds security to ssh itself. It does block apps opening ports, as you point out.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#29SSM
Assuming you're using Amazon Linux 2 as your AMI, it's just as simple as assigning a instance profile with the right permissions (you can use the managed AmazonSSMManagedInstanceCore policy [2]). And you'll then be able to connect through the AWS Console or CLI.
[1]: https://docs.aws.amazon.com/systems-manager/latest/userguide...
[2]: https://console.aws.amazon.com/iam/home#/policies/arn:aws:ia...
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#30You could try using Tailscale. It's a wireguard based mesh VPN. Just set it up on your device, your server, and you're good to go. You can just only allow SSH over Tailscale, without worrying about anybody else trying to get in. Other alternatives include ZeroTier and Nebula afaik, but I've never tried either. (Still use SSH keys regardless though.)
Zerotier is the easy way around. Also remember to block all ssh access at standard ports.