ssh远程端口转发到本地_Linux SSH隧道或端口转发本地和远程端口的示例?
ssh遠程端口轉發到本地
Ssh protocol secures remote connections which are shell or terminal-based to the remote systems. Ssh protocol and tool provides more than that. We can use ssh?to create tunnels over local and remote systems or connect remote system X server. In this tutorial, we will look at how to tunnel and port forward locally and remotely.
Ssh協議可保護基于Shell或終端的遠程連接與遠程系統的安全。 SSH協議和工具還提供了更多功能。 我們可以使用ssh在本地和遠程系統上創建隧道,或者連接遠程系統X服務器。 在本教程中,我們將研究如何在本地和遠程隧道和端口轉發。
本地端口轉發–將本地系統端口轉發或隧道傳輸到遠程系統端口 (Local Port Forwarding – Forward or Tunnel Local System Port To Remote System Port)
Local port forwarding or tunneling is used to forward given local port to the given remote system port. We need to specify three things
本地端口轉發或隧道用于將給定的本地端口轉發到給定的遠程系統端口。 我們需要指定三件事
- LOCAL_PORTLOCAL_PORT
- DESTINATION_HOST DESTINATION_HOST
- DESTINATION_PORT 目的端口
and the syntax is like below.
語法如下。
ssh -L LOCALPORT : DESTINATIONHOST : DESTINATIONPORT REMOTE_HOSTIn this example we will connect to the 192.168.122.22?with ssh and forward our local 2222?port to the poftut.com?2222?port like below.
在此示例中,我們將使用ssh連接到192.168.122.22 ,并將本地2222端口轉發到poftut.com 2222端口,如下所示。
$ ssh -L 2222:poftut.com:2222 192.168.122.22 Local Port Forwarding – Forward or Tunnel Local System Port To Remote System Port本地端口轉發–將本地系統端口轉發或隧道傳輸到遠程系統端口遠程端口轉發–將遠程系統端口轉發或隧道到本地系統端口(Remote Port Forwarding – Forward or Tunnel Remote System Port To Local System Port)
This is the same operation where the given remote port is connected to the given local port. We will connect remote system port 22?to our local system port 2222?. We will just change -L?local option to the -R?remote option.
給定的遠程端口連接到給定的本地端口時,這是相同的操作。 我們將遠程系統端口22連接到本地系統端口2222 。 我們只是將-L local選項更改為-R remote選項。
$ ssh -R 2222:poftut.com:2222 192.168.122.22動態端口轉發 (Dynamic Port Forwarding)
Dynamic port forwarding will use SOCKS which default port number is 1080. But another port number can be used. SOCKS generally used to proxy browsers like Chrome, Firefox, Opera. Proxy traffic will be forwarded to the remote system.
動態端口轉發將使用SOCKS,其默認端口號為1080。但是可以使用其他端口號。 SOCKS通常用于代理瀏覽器,例如Chrome,Firefox,Opera。 代理流量將轉發到遠程系統。
$ ssh -D 1080 192.168.122.22 Dynamic Port Forwarding動態端口轉發X11通過SSH Tunelling轉發(X11 Forwarding via SSH Tunelling)
Linux systems use for the GUI X11 server. One of the best features of SSH is a remote application with GUI can be run on local system. The application actually runs on a remote system but GUI or X11 protocol is forwarded to the local system and shown as a local application. To enable forwarding to provide?-X?parameter.
Linux系統用于GUI X11服務器。 SSH的最佳功能之一是帶有GUI的遠程應用程序,可以在本地系統上運行。 該應用程序實際上在遠程系統上運行,但是GUI或X11協議被轉發到本地系統并顯示為本地應用程序。 要啟用轉發,請提供-X參數。
$ ssh -X 192.168.122.22 X11 ForwardingX11轉發OR
要么
Just with a single shot
只需一次拍攝
$ ssh -X 192.168.122.22 firefox X11 ForwardingX11轉發 .u36c93c4c0822bab99e6135612bff6159 , .u36c93c4c0822bab99e6135612bff6159 .postImageUrl , .u36c93c4c0822bab99e6135612bff6159 .centered-text-area { min-height: 80px; position: relative; } .u36c93c4c0822bab99e6135612bff6159 , .u36c93c4c0822bab99e6135612bff6159:hover , .u36c93c4c0822bab99e6135612bff6159:visited , .u36c93c4c0822bab99e6135612bff6159:active { border:0!important; } .u36c93c4c0822bab99e6135612bff6159 .clearfix:after { content: ""; display: table; clear: both; } .u36c93c4c0822bab99e6135612bff6159 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u36c93c4c0822bab99e6135612bff6159:active , .u36c93c4c0822bab99e6135612bff6159:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u36c93c4c0822bab99e6135612bff6159 .centered-text-area { width: 100%; position: relative; } .u36c93c4c0822bab99e6135612bff6159 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u36c93c4c0822bab99e6135612bff6159 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u36c93c4c0822bab99e6135612bff6159 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u36c93c4c0822bab99e6135612bff6159:hover .ctaButton { background-color: #E67E22!important; } .u36c93c4c0822bab99e6135612bff6159 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u36c93c4c0822bab99e6135612bff6159 .u36c93c4c0822bab99e6135612bff6159-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u36c93c4c0822bab99e6135612bff6159:after { content: ""; display: block; clear: both; } LEARN MORE? Linux Lsof Command Tutorial With Examples .u36c93c4c0822bab99e6135612bff6159 , .u36c93c4c0822bab99e6135612bff6159 .postImageUrl , .u36c93c4c0822bab99e6135612bff6159 .centered-text-area { min-height: 80px; position: relative; } .u36c93c4c0822bab99e6135612bff6159 , .u36c93c4c0822bab99e6135612bff6159:hover , .u36c93c4c0822bab99e6135612bff6159:visited , .u36c93c4c0822bab99e6135612bff6159:active { border:0!important; } .u36c93c4c0822bab99e6135612bff6159 .clearfix:after { content: ""; display: table; clear: both; } .u36c93c4c0822bab99e6135612bff6159 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u36c93c4c0822bab99e6135612bff6159:active , .u36c93c4c0822bab99e6135612bff6159:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u36c93c4c0822bab99e6135612bff6159 .centered-text-area { width: 100%; position: relative; } .u36c93c4c0822bab99e6135612bff6159 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u36c93c4c0822bab99e6135612bff6159 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u36c93c4c0822bab99e6135612bff6159 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u36c93c4c0822bab99e6135612bff6159:hover .ctaButton { background-color: #E67E22!important; } .u36c93c4c0822bab99e6135612bff6159 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u36c93c4c0822bab99e6135612bff6159 .u36c93c4c0822bab99e6135612bff6159-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u36c93c4c0822bab99e6135612bff6159:after { content: ""; display: block; clear: both; } 了解更多帶有示例Linux Lsof命令教程翻譯自: https://www.poftut.com/linux-ssh-tunneling-or-port-forwarding-local-and-remote-ports-with-examples/
ssh遠程端口轉發到本地
總結
以上是生活随笔為你收集整理的ssh远程端口转发到本地_Linux SSH隧道或端口转发本地和远程端口的示例?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [学习笔记] Matrix tree定理
- 下一篇: linux 其他常用命令