通过ssh网关连接到RabbitMQ(Amqp)

我有以下情况: DevMachine (D) need to connect to a gateway/bastion server (G) and then be able to talk to another server serving RabbitMQ (R) traffic on port 5672.

我尝试使用ssh隧道到网关: ssh -L 5672:localhost:5672 G和接下来我想让网关实例让我连接到R的5672.我该如何做到这一点? 我觉得我在这里错过了一步。

我想要什么: D ->G -> R 我得到的是D ->G 如果我有一个在G上本地运行的rabbitmq实例 – 这可行,但我想要的是基本上使用G作为VPN。

谢谢!

如果要连接到远程主机,则需要使用其名称,而不是localhost

 ssh -L 5672:R:5672 G 

通过这种方式,您应该能够访问localhost:5672上的主机R localhost:5672