TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How can I secure my AWS instance's SSH access if I have no static IP?

13 点作者 gkrishna超过 3 年前
When I try to create a new instance on AWS, I get a warning:<p>`Rules with source of 0.0.0.0&#x2F;0 allow all IP addresses to access your instance. We recommend setting security group rules to allow access from known IP addresses only.`<p>What are alternative security measures that I can apply to protect my servers?

14 条评论

gregjor超过 3 年前
If you don&#x27;t allow password logins so ssh only accepts public&#x2F;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&#x27;t going to succeed anyway. As far as I know it&#x27;s not possible to brute force or otherwise hack ssh with ssl keypair authentication directly. An attacker would need access to your ssl private key. The ssh protocol resists MITM attacks as well.<p>If anyone knows about actual working attacks on ssh servers that don&#x27;t allow password authentication I&#x27;d like to know about it. I don&#x27;t mean state-level attackers who would probably hack into your laptop or strong-arm the hosting provider.
评论 #30383257 未加载
评论 #30383897 未加载
iiix超过 3 年前
You could try using Tailscale. It&#x27;s a wireguard based mesh VPN. Just set it up on your device, your server, and you&#x27;re good to go. You can just only allow SSH over Tailscale, without worrying about anybody else trying to get in.<p>Other alternatives include ZeroTier and Nebula afaik, but I&#x27;ve never tried either.<p>(Still use SSH keys regardless though.)
评论 #30383326 未加载
评论 #30383251 未加载
indigodaddy超过 3 年前
Oracle has a generous free tier for OCI instances&#x2F;VMs, and includes a public IP. You can use that as an ssh bastion&#x2F;jumphost.<p>Or if don’t want to do business with Oracle, you can find VPS&#x2F;VM providers who offer tiny instances for $10-12&#x2F;yr or less. You don’t need much ram for a bastion. 128M ram would do the trick, and even 64M (you’d have to use a stripped down image&#x2F;distro though).<p>There are even providers who offer instances for even less $ and only give you an ipv6 range + NAT IPv4 address with a small port range. This would also work perfectly fine as a bastion.
评论 #30383264 未加载
评论 #30383244 未加载
评论 #30382821 未加载
reacharavindh超过 3 年前
An AWS specific solution would be to use Systems Manager Sessions Manager to provide access into the instances and disallow all public access to the instances. No SSH. Identity is provided by IAM. As long as you use AWS cli and have configured it to login with your IAM creds, you can simply get a session via SSM. Added bonus is the ability to easily get an audit log in cloudwatch&#x2F;S3. And no SSH keys&#x2F;Linux user accounts to manage.<p>We use this for all our bastion hosts.
评论 #30392729 未加载
YuriNiyazov超过 3 年前
Just update the security group to your new IP address when it changes. You can also run a VPN, but that&#x27;s more expensive
wizwit999超过 3 年前
Definitely use SSM, it takes care of everything for you and you don&#x27;t need a bastion.
cdegro超过 3 年前
Set your current IP in the security group and update it whenever it changes. You could make the update through the aws cli, this way you don’t have to login into the console every time
mhio超过 3 年前
ip=$(curl <a href="https:&#x2F;&#x2F;api.ipify.org" rel="nofollow">https:&#x2F;&#x2F;api.ipify.org</a>)<p>tag_name=&quot;tmpip&quot;<p>tag_time=$(date -u &#x27;+%Y-%m-%dT%H:%M:%SZ&#x27;)<p>aws ec2 authorize-security-group-ingress --group-id sg-86169665d2453e4 --protocol tcp --port 22 --cidr &quot;$ip&#x2F;32&quot; --tag-specifications &quot;ResourceType=security-group-rule,Tags=[{Key=Name,Value=${tag_name}},{Key=added,Value=${tag_time}}]&quot;<p>The tag enables replacing the existing rule via tag Name, the further you go the easier it is to use the API SDKs
评论 #30386780 未加载
tragictrash超过 3 年前
Use ssh pubkey auth and disable password. Set up a totp challenge after pubkey auth. Switch the default ssh port. Restrict ssh login to 1 user who&#x27;s name isn&#x27;t &#x27;root&#x27; or &#x27;ubuntu&#x27; or something everyone would look for. Wrap that in wireguard, and have ssh only listen on the wireguard interface if your worried, but that&#x27;s an unnecessary extra step.
smittywerben超过 3 年前
I&#x27;m lazy and just manually update my IP in the security group. It&#x27;s not like the server shuts down when my home IP changes.
vgeek超过 3 年前
Disallow password logins, change ssh port, change&#x2F;hide sshd identity information or configure port knocking.
评论 #30383291 未加载
steffan超过 3 年前
Even if you don’t have a static IP, you can probably restrict to a &#x2F;24 subnet or maybe &#x2F;16.<p>Additionally, you can ensure password access is disabled and use ssh keys along with 2FA.
评论 #30383334 未加载
评论 #30382961 未加载
JMS2021超过 3 年前
SSM
评论 #30383597 未加载
more_corn超过 3 年前
Tailscale, Openvpn, Your isp probably only rotates your IP every 2 weeks