【发布时间】:2022-01-11 13:48:09
【问题描述】:
我有一个 IP 地址列表。我想允许来自他们的tcp/22 流量并阻止任何其他IP 地址。该列表很长,包含大约 50-60 个 IP 地址。如何在不手动添加的情况下将其添加到安全组中。
谢谢!
解决方案:
我找到了一种使用aws cli的方法
允许 SSH 访问一系列 cidrs
bash# for ip in {csv_list_of_cidrs}
> do
> aws ec2 authorize-security-group-ingress --group-id <sg_ig_here> --protocol tcp --port 22 --cidr $ip
> done
例如:
for ip in {1.1.1.1/8,2.2.2.2/16,3.2.3.12/29}
do
aws ec2 authorize-security-group-ingress --group-id sg-xxxxxxxxx --protocol tcp --port 22 --cidr $ip
done
使用boto3的解决方案参考下面的答案
【问题讨论】:
-
这些 ips 是否存储在文件中?
标签: amazon-web-services aws-security-group