大网数据广告活动
服务器运维问答

Amazon EC2 Security Group inbound rule with a dynamic IP

· 52CE 我爱测

I'm looking for clarification on what I see as a potential problem with EC2 Security Groups. I'm setting up a Security Group for connecting to linux instances. I've created "anywhere" rules for HTTP and HTTPS access. For my SSH r…

问题原文

原帖链接 · Will Byrne · CC BY-SA 3.0

I'm looking for clarification on what I see as a potential problem with EC2 Security Groups.

I'm setting up a Security Group for connecting to linux instances. I've created "anywhere" rules for HTTP and HTTPS access.

For my SSH rule, the amazon tutorial says I should limit inbound access to my public IP address.

  1. What I don't get is how that's secure or workable if your public IP address is dynamic?

  2. My IP address is dynamic, so what happens when my ISP changes my public IP and I can no longer ssh into my instance?

Link to the setup guide I'm using: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html (Step 7 of 'Create a Security Group' is what seems problematic to me)

已采纳解答

原帖链接 · Drew Khoury · CC BY-SA 3.0

What I don't get is how that's secure or workable if your public IP address is dynamic?

This solution could work if you find your IP doesn't change often, or if you only need access for a short time. It adds an extra layer of security as SSH isn't exposed to traffic outside of the CIDR you supply.

If a specific CIDR doesn't work, you could try on or more board CIDR ranges that your ISP is likely to use, this will still limit access from a large percentage of the Internet, and that's a win for security.

what happens when my ISP changes my public IP and I can no longer ssh into my instance?

You can login to the AWS Console, or use the CLI to update the Security Group rule on the fly.

You could write a script that interacts with the CLI directly. It could be as simple as something that checks for the Port 22 rule against your current IP and updates it if it's different. Of course running such a script might raise more security questions itself :)

Is an IP firewall the best way to secure SSH?

While it's nice to limit ssh traffic to only trusted IP sources where practical, the thing that makes ssh secure is the use of private keys and sensible configuration.

Key items to consider:

  • Add a passphrase to your SSH private key
  • Disable password auth to SSH
  • Disable root login to SSH
  • Audit all user accounts for SSH public keys

You could also do a few things to get rid of the 'noise' associated with brute force attacks:

  • Run ssh on a higher port
  • Use software like fail2ban which will dynamically log numerous failed attempt and block IP ranges for specified periods of time

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-06-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。