ssh远程端口转发到本地_Linux SSH隧道或端口转发本地和远程端口的示例?
ssh遠(yuǎn)程端口轉(zhuǎn)發(fā)到本地
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協(xié)議可保護(hù)基于Shell或終端的遠(yuǎn)程連接與遠(yuǎn)程系統(tǒng)的安全。 SSH協(xié)議和工具還提供了更多功能。 我們可以使用ssh在本地和遠(yuǎn)程系統(tǒng)上創(chuàng)建隧道,或者連接遠(yuǎn)程系統(tǒng)X服務(wù)器。 在本教程中,我們將研究如何在本地和遠(yuǎn)程隧道和端口轉(zhuǎn)發(fā)。
本地端口轉(zhuǎn)發(fā)–將本地系統(tǒng)端口轉(zhuǎn)發(fā)或隧道傳輸?shù)竭h(yuǎn)程系統(tǒng)端口 (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
本地端口轉(zhuǎn)發(fā)或隧道用于將給定的本地端口轉(zhuǎn)發(fā)到給定的遠(yuǎn)程系統(tǒng)端口。 我們需要指定三件事
- 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端口轉(zhuǎn)發(fā)到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本地端口轉(zhuǎn)發(fā)–將本地系統(tǒng)端口轉(zhuǎn)發(fā)或隧道傳輸?shù)竭h(yuǎn)程系統(tǒng)端口遠(yuǎn)程端口轉(zhuǎn)發(fā)–將遠(yuǎn)程系統(tǒng)端口轉(zhuǎn)發(fā)或隧道到本地系統(tǒng)端口(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.
給定的遠(yuǎn)程端口連接到給定的本地端口時(shí),這是相同的操作。 我們將遠(yuǎn)程系統(tǒng)端口22連接到本地系統(tǒng)端口2222 。 我們只是將-L local選項(xiàng)更改為-R remote選項(xiàng)。
$ ssh -R 2222:poftut.com:2222 192.168.122.22動(dòng)態(tài)端口轉(zhuǎn)發(fā) (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.
動(dòng)態(tài)端口轉(zhuǎn)發(fā)將使用SOCKS,其默認(rèn)端口號(hào)為1080。但是可以使用其他端口號(hào)。 SOCKS通常用于代理瀏覽器,例如Chrome,Firefox,Opera。 代理流量將轉(zhuǎn)發(fā)到遠(yuǎn)程系統(tǒng)。
$ ssh -D 1080 192.168.122.22 Dynamic Port Forwarding動(dòng)態(tài)端口轉(zhuǎn)發(fā)X11通過SSH Tunelling轉(zhuǎn)發(fā)(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系統(tǒng)用于GUI X11服務(wù)器。 SSH的最佳功能之一是帶有GUI的遠(yuǎn)程應(yīng)用程序,可以在本地系統(tǒng)上運(yùn)行。 該應(yīng)用程序?qū)嶋H上在遠(yuǎn)程系統(tǒng)上運(yùn)行,但是GUI或X11協(xié)議被轉(zhuǎn)發(fā)到本地系統(tǒng)并顯示為本地應(yīng)用程序。 要啟用轉(zhuǎn)發(fā),請(qǐng)?zhí)峁?strong>-X參數(shù)。
$ ssh -X 192.168.122.22 X11 ForwardingX11轉(zhuǎn)發(fā)OR
要么
Just with a single shot
只需一次拍攝
$ ssh -X 192.168.122.22 firefox X11 ForwardingX11轉(zhuǎn)發(fā) .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遠(yuǎn)程端口轉(zhuǎn)發(fā)到本地
總結(jié)
以上是生活随笔為你收集整理的ssh远程端口转发到本地_Linux SSH隧道或端口转发本地和远程端口的示例?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [学习笔记] Matrix tree定理
- 下一篇: 51CTO学习笔记--Linux运维故障