EC2 如何允许 SSH 隧道访问私有子网中的 RDS?
How EC2 allow SSH tunelling to access RDS in private subnet?
要访问私有子网中的 RDS,在以下架构中,
给出EC2的public IP,EC2在public子网中的ssh私钥位置,私有子网中RDS的DB凭据,如下图,
EC2(在 public 子网中)如何允许通过 ssh 隧道连接到私有子网中的 RDS?与EC2中的/etc/ssh/sshd_config
有关吗?
从图中可以看出,EC2
实例共享在 RDS
上定义的相同 private network (class B) 172.16.X.X
with the RDS
therefore by having access to any instance in the public segment and depending on the security groups 可能可以通过执行以下操作访问数据库:
ssh -L 3307:<db>.rds.amazonaws.com:3306 user@your.ec2
选项 -L
将通过 your.ec2.instance
从端口 3307
(您的计算机)到 <db>.rds.amazonaws.com
中的端口 3306
进行本地端口转发。
您可以使用 bastion
主机来执行此操作,您可以在此处阅读更多相关信息:https://docs.aws.amazon.com/quickstart/latest/linux-bastion/architecture.html
除了定义允许使用 ssh 的用户的方式和内容之外,您不必处理 sshd_config
大部分工作将在 AWS 安全组中或您如何定义您的 VPC or network ACL's.
要访问私有子网中的 RDS,在以下架构中,
给出EC2的public IP,EC2在public子网中的ssh私钥位置,私有子网中RDS的DB凭据,如下图,
EC2(在 public 子网中)如何允许通过 ssh 隧道连接到私有子网中的 RDS?与EC2中的/etc/ssh/sshd_config
有关吗?
从图中可以看出,EC2
实例共享在 RDS
上定义的相同 private network (class B) 172.16.X.X
with the RDS
therefore by having access to any instance in the public segment and depending on the security groups 可能可以通过执行以下操作访问数据库:
ssh -L 3307:<db>.rds.amazonaws.com:3306 user@your.ec2
选项 -L
将通过 your.ec2.instance
从端口 3307
(您的计算机)到 <db>.rds.amazonaws.com
中的端口 3306
进行本地端口转发。
您可以使用 bastion
主机来执行此操作,您可以在此处阅读更多相关信息:https://docs.aws.amazon.com/quickstart/latest/linux-bastion/architecture.html
除了定义允许使用 ssh 的用户的方式和内容之外,您不必处理 sshd_config
大部分工作将在 AWS 安全组中或您如何定义您的 VPC or network ACL's.