通过 Windows/PuTTY 的 PostgreSQL SSH 端口转发

PostgreSQL SSH port forwarding via Windows/PuTTY

我在 Linux VPS 上运行 PostgreSQL 9.4,我需要能够从 Linux 和 Windows 客户端通过 SSH 连接到它。 (我稍后需要连接到多个服务器,以便所有客户端使用相同的端口号,我将转发到第一个服务器的端口 5551,然后我将使用 5552、5553 等)

我从 Linux 客户端运行 ssh -fNg -L 5551:localhost:5432 user@remote1.com 并使用 PGAdmin3 或任何其他客户端应用程序连接到 localhost:5551。效果很好。

在 Windows,我正在使用 PuTTY 和 Pageant。我通过终端工作连接到 user@remote1.com,然后我去了 SSH 隧道并添加了 L5432 localhost:5551。终端连接仍然有效,但是当我尝试将 PGAdmin3 连接到 localhost:5551 时,出现错误:

could not connect to server: Connection refused (0x0000274AD/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5551?

我解决了。与许多事情一样,事后看来这是显而易见的。我在 PuTTY 的 SSH 隧道设置中遇到了一些问题。需要 L5551 remote1.com:5432