【发布时间】:2021-10-16 07:48:13
【问题描述】:
将 ssh 连接到堡垒主机后如何连接 rds 私有实例。
我创建了一个具有以下配置的 VPC:
- 公共子网中的堡垒(EC2 实例)
- 两个私有子网,连接到 AWS RDS...
我能够通过 SSH 进入堡垒,但我无法像在本地使用 psql postgres 那样访问 postgres。
我尝试从这里执行步骤:https://aws.amazon.com/premiumsupport/knowledge-center/rds-connect-using-bastion-host-linux/ 但我无法复制私钥,它太长并且不起作用
我也试过psql --host=yyy.xxx.us-east-z.rds.amazonaws.com --port=5432 --username=someusername --password --dbname=postgres,这是有人通过psql连接的方式,我在终端收到的错误消息是The program 'psql' is currently not installed. You can install it by typing...(我不应该安装psql,我想因为使用公共RDS我不安装它...,不是吗?)
目前唯一有效的是我可以telnet RDS Endpoint:5432 并且它有效
我正在使用 terraform,所以我的安全组是:
resource "aws_security_group" "rds" {
name = "rds"
vpc_id = aws_vpc.main.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
protocol = "tcp"
from_port = 5432
to_port = 5432
cidr_blocks = ["0.0.0.0/0"]
}
}
任何帮助都会有所帮助
【问题讨论】:
-
“但它不起作用” - 不具体。到底发生了什么?有什么错误吗?您的安全组是什么?
-
@Marcin 抱歉,我刚刚更新了帖子。谢谢
-
您的帖子令人困惑。首先你有关于 dns 错误的问题,现在关于缺少 psql?你到底在做什么?
-
@Marcin 我意识到我不再在堡垒之内,所以我回到了它。我只想从我目前在其中的堡垒 ec2 实例连接到 RDS 私有实例
-
@Marcin 我真的可以打败自己,我认为没有必要,但它实际上是解决方案,我现在在 RDS 中,谢谢
标签: postgresql amazon-web-services amazon-ec2 aws-lambda