
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.
-R [bind_address:]port:host:hostport
Specifies that the given port on the remote (server) host is to
be forwarded to the given host and port on the local side.
這兩個描述是不是混淆了?
當我使用ssh -L
它時,它需要一個遠端端口並將其“綁定”(或轉發)到本地計算機上的端口,以便我可以通過與自己對話(localhost:port)來與某些遠端計算機進行對話。
當我使用ssh -R
它時,它從本地網路上的電腦獲取一個端口,並將其「綁定」(或轉發)到遠端電腦(ssh 伺服器)上的端口。然後,當我在伺服器上時,我可以與我剛剛使用(localhost:port)連接的電腦位於同一網路上的電腦連接埠進行通訊。
這也解釋了使用 L 表示本地、R 表示遠端(無論連接埠綁定到何處)。
(我不知道我是否正確使用了「綁定」這個詞。這不是我試圖用引號暗示的意思)
答案1
你對「前進」的定義混淆了。它是轉發的資料包(對於 ,從本地到遠程,對於-L
,從遠端到本地-R
)。