SSH隧道建立成功,但telnet測試仍然失敗

SSH隧道建立成功,但telnet測試仍然失敗

我在 RHEL 5 系統上連接到另一個 RHEL 5 系統。我使用以下命令創建了 SSH 隧道:ssh -2 -4 -f -x -N -L 1527:遠端主機:1527 使用者@遠端主機

(remote_host是同一台伺服器)

我輸入密碼,然後立即返回命令提示字元。我快速運行了 'ps axu | grep ssh' 來驗證並查看我剛剛執行的 ssh 命令的進程:

dashbrd  17861  0.0  0.1  68796 13224 ?        Ss   12:44   0:00 ssh -2 -4 -f -x -N -L 1527:remote_host:1527 user@remote_host

我假設我的隧道已成功建立。

然後我使用“telnet remote_host 1527”進行測試,但無法連線;在我殺死它之前只是掛起幾分鐘。我在本機上嘗試使用不同使用者(包括我用於建立隧道的使用者名稱)進行telnet測試,結果是相同的 - 沒有連線。

此隧道的目的是連接到 Oracle 偵聽器。所以,我運行tnsping公用事業;也無法連接。 (是的,我在 tnsnames.ora 檔案中正確配置了資料庫連線。)

我做錯了什麼?

答案1

您不會遠端登入remote_host,而是遠端登入本機。如果您可以直接遠端登入remote_host,則不需要連接埠向前

telnet localhost 1527

從 ssh 手冊頁:

 -L [bind_address:]port:host:hostport
         Specifies that the given port on the local (client) host is to be
         forwarded to the given host and port on the remote side.  This
         works by allocating a socket to listen to port on the local side,
         optionally bound to the specified bind_address.  Whenever a con-
         nection is made to this port, the connection is forwarded over
         the secure channel, and a connection is made to host port
         hostport from the remote machine.  Port forwardings can also be
         specified in the configuration file.  IPv6 addresses can be spec-
         ified with an alternative syntax:
         [bind_address/]port/host/hostport or by enclosing the address in
         square brackets.  Only the superuser can forward privileged
         ports.  By default, the local port is bound in accordance with
         the GatewayPorts setting.  However, an explicit bind_address may
         be used to bind the connection to a specific address.  The
         bind_address of “localhost” indicates that the listening port be
         bound for local use only, while an empty address or ‘*’ indicates
         that the port should be available from all interfaces.

相關內容