简体   繁体   English

使用 DBeaver 进行多个 SSH 隧道跃点

[英]Multiple SSH tunnel hops with DBeaver

Can DBeaver create two SSH tunnels and then connect to a database? DBeaver 可以创建两个 SSH 隧道然后连接到数据库吗?

I have successfully created one SSH tunnel but not two.我已经成功创建了一个 SSH 隧道,但没有创建两个。

I am trying to connect to an AWS RDS database via Bastion host.我正在尝试通过 Bastion 主机连接到 AWS RDS 数据库。 Bastion host only allows SSH access from my corporate IP range.堡垒主机仅允许从我的公司 IP 范围访问 SSH。 This means that when I am in the office I can connect to the RDS from DBeaver just fine:这意味着当我在办公室时,我可以很好地从 DBeaver 连接到 RDS:

  1. My computer is in the allowed IP range我的电脑在允许的 IP 范围内
  2. DBeaver creates an SSH tunnel to a Bastion host in my VPC inside the AWS cloud DBeaver 创建一个 SSH 隧道到我在 AWS 云中的 VPC 中的堡垒主机
  3. DBeaver connects to the RDS database DBeaver 连接到 RDS 数据库

The issue arises when I work from home.当我在家工作时,就会出现这个问题。 I would have to add "zero" step to have an allowed IP address for the Bastion host connection: 0) Connect to the machine inside the office我必须添加“零”步骤以获得允许的 IP 地址用于堡垒主机连接:0)连接到办公室内的机器

I have not yet managed to achieve this.我还没有做到这一点。 Has anyone got an idea of how to do this?有没有人知道如何做到这一点?

Kudos to @erik258 for pointing me in the right direction.感谢@erik258为我指明了正确的方向。

I have created an SSH tunnel between an office machine and the Bastion host.我在办公机器和堡垒主机之间创建了一条 SSH 隧道。 When in the office machine, when I access http://localhost:<local_port> I am in effect communicating with the <RDS_endpoint> on port <remote_port> .在办公室机器中,当我访问http://localhost:<local_port>时,我实际上是在与端口<remote_port> <RDS_endpoint>上的 <RDS_endpoint> 通信。

Steps:脚步:

  1. Create an SSH tunnel from the office machine to the Bastion host.创建从办公机器到堡垒主机的 SSH 隧道。 Source资源

$ ssh -L <local_port>:<RDS_endpoint>:<remote_port> -i <path_to_ssh_key> ec2-user@<Bastion_host public IP> $ ssh -L <local_port>:<RDS_endpoint>:<remote_port> -i <path_to_ssh_key> ec2-user@<Bastion_host 公共 IP>

<local_port> - random port <local_port> - 随机端口

<remote_port> - port RDS endpoint listens to (5432 for PostgreSQL) <remote_port> - RDS 端点侦听的端口(对于 PostgreSQL 为 5432)

<RDS_endpoint> - endpoint specified on the AWS RDS page <RDS_endpoint> - 在 AWS RDS 页面上指定的端点

  1. Create DBeaver connection.创建 DBeaver 连接。 In the "SSH" section specify your office machine.在“SSH”部分指定您的办公机器。 In "Main" section, set "Host" as localhost , and "Port" as <local_port> .在“Main”部分,将“Host”设置为localhost ,将“Port”设置为<local_port>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM