Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
31–40 of 48 posts
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#32tag_name="tmpip"
tag_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
aws ec2 authorize-security-group-ingress --group-id sg-86169665d2453e4 --protocol tcp --port 22 --cidr "$ip/32" --tag-specifications "ResourceType=security-group-rule,Tags=[{Key=Name,Value=${tag_name}},{Key=added,Value=${tag_time}}]"
The tag enables replacing the existing rule via tag Name, the further you go the easier it is to use the API SDKs
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#33We use this for all our bastion hosts.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#34Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#35If 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…
I don’t think state level actors can compromise it, if properly configured.
It’s far easier to hack the end point and steal the keys.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#36Earlier quoted context omitted.
Is changing SSH port really necessary? If your SSH is vulnerable, attackers will find the Port for it.
Surprisingly, just changing the port is highly effective. Scanning every ipv4 address still chews bandwidth even for just a handful of ports. 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?
#37Earlier quoted context omitted.
Zerotier is the easy way around. Also remember to block all ssh access at standard ports.
That implies running SSH on another, non-standard port makes it safer -- when a simple port scan would reveal it. It's a classic security through obscurity fallacy, IMHO,
Sure " simple port scan would reveal it" - but for those other script kiddes that do not do have it prevents it. And BTW, every bit helps of security helps. zerotier at an alternative port is slightly better than port 22.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#38Earlier quoted context omitted.
You would set it based on the range your ISP tends to assign you, and remove 0.0.0.0 for the ssh port.
Unfortunately. I have seen some ISPs DHCP servers assign IPs with no particular subnet(s). Could be a case here as well.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#39Earlier quoted context omitted.
I find this very useful. I will setup a bastion. Thank you
On your ssh bastion make sure to at the very least: - have minimal services running, preferably only ssh - if you have other services running then use iptables or a firewall frontend to block all incoming ports except for the ones you specifically need/want open - disable root ssh login - disable password login (eg use ssh keys and preferably with a passphrase too) - you can also use something like fail2ban or denyho…
that way i would not need to keep the keys in the bastion server at all.
Re: Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?
#40ip=$(curl https://api.ipify.org ) tag_name="tmpip" tag_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ') aws ec2 authorize-security-group-ingress --group-id sg-86169665d2453e4 --protocol tcp --port 22 --cidr "$ip/32" --tag-specifications "ResourceType=security-group-rule,Tags=[{Key=Name,Value=${tag_name}},{Key=added,Value=${tag_time}}]" The tag enables replacing the existing rule via tag Name, the further you go the easier it is…