Last active
September 29, 2017 16:04
-
-
Save codeachange/78215b362040928a0dc639ac82dba5a7 to your computer and use it in GitHub Desktop.
ssh reverse tunnel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ssh反向隧道,实现NAT穿透 | |
| # 在局域网内执行 | |
| # 把局域网内的 192.168.1.100:443 暴露到 138.47.99.99:19999 | |
| ssh -R 19999:192.168.1.100:443 [email protected] | |
| # 暴露后的 138.47.99.99:19999 貌似只能本地访问,即 telnet localhost 19999 是通的,远程 telnet 138.47.99.99 19999 不通 | |
| # 如果只是做ssh跳板机,上面就够了,先ssh到138.47.99.99再ssh localhost -p 19999 | |
| # 如果要实现网页访问,即远程通过公网IP访问19999端口 | |
| # 则需要再来一次ssh tunnel | |
| # 把 138.47.99.99:19999 端口暴露到本地 12345,然后可用浏览器访问 https://localhost:12345 实际访问局域网 192.168.1.100:443 | |
| ssh -L 12345:localhost:19999 [email protected] | |
| # Reference | |
| # https://www.howtoforge.com/reverse-ssh-tunneling | |
| # https://chamibuddhika.wordpress.com/2012/03/21/ssh-tunnelling-explained/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment