【发布时间】:2021-09-05 19:34:25
【问题描述】:
我想从本地通过 EC2 连接到 AWS RDS。
我在本地机器上创建了一个隧道:
ssh -i ~/.ssh/id_rsa -f -N -L 5432:RDS-Endpoint:5432 EC2-User@EC2-IP -v
这种方式可行:
psql -hlocalhost -Upostgres -p5432 -d postgres
它确实连接到 RDS db。
但是如果使用另一个具有 SSL 证书的 postgres 用户
psql -hlocalhost -p5432 "sslmode=verify-full sslrootcert=rds-ca-2019-root.pem user=another_user dbname=my_db"
导致此错误:
psql: error: server certificate for "tf-xxx.rds.amazonaws.com" (and 2 other names) does not match host name "localhost"
如果在 EC2 服务器上做,效果很好。在本地,证书似乎与localhost 不匹配。那么如何正确设置呢?
【问题讨论】:
标签: postgresql amazon-web-services localhost amazon-rds ssh-tunnel