{"id":104,"date":"2023-10-13T17:59:44","date_gmt":"2023-10-13T09:59:44","guid":{"rendered":"https:\/\/blog.quantoyo.com\/?p=104"},"modified":"2024-09-27T14:01:37","modified_gmt":"2024-09-27T06:01:37","slug":"ssh-%e9%80%9a%e9%81%93ssh-tunnel","status":"publish","type":"post","link":"https:\/\/blog.quantoyo.com\/?p=104","title":{"rendered":"SSH \u901a\u9053(SSH Tunnel &#038; SSH proxy)"},"content":{"rendered":"\n<p>SSH Tunnel\u662f\u57fa\u65bcSSH \u7684\u4e00\u7a2e\u61c9\u7528\u65b9\u5f0f\uff0c\u53ef\u5728\u5169\u500bserver\u9593\u5efa\u7acb\u5b89\u5168\u7684\u901a\u9053<br>\u5206\u5169\u7a2e\u61c9\u7528\u65b9\u5f0f<\/p>\n\n\n\n<!--more-->\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u628a\u9060\u7aef\u6a5f\u5668\u4e0a\u5176\u4ed6\u61c9\u7528\u7a0b\u5f0f\u76e3\u807d\u7684port \u8f49\u63a5\u5230\u672c\u6a5f\u4e0a\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u672c\u6a5f\u4e0atelnet \u8a72port<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>ssh quanto@192.168.10.2 -L 19988:192.168.10.2:9988  -L 19989:192.168.10.2:9989\n\n\u9019\u6a23\u53ef\u4ee5\u4f7f\u672c\u6a5f\u4e0a\u4e5f\u80fd\u76f4\u63a5\u4e0b\u6307\u4ee4 \ntelnet 127.0.0.1 19988 \u9023\u5230\u9060\u7aef\u6a5f\u5668\u76849988 port\ntelnet 127.0.0.1 19989 \u9023\u5230\u9060\u7aef\u6a5f\u5668\u76849989 port<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u958b\u555fproxy<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>ssh -fN -D 7777 quanto@192.168.10.2\n\n\u9019\u6a23\u53ef\u4ee5\u958b\u555fssh proxy \u529f\u80fd\uff0c\u53ea\u8981\u6307\u5b9a\u8a72proxy \u5c31\u53ef\u4ee5\u76f8\u7576\u65bc\u5728\u9060\u7aef\u6a5f\u5668\u57f7\u884c\u7a0b\u5f0f\nps.\n    f \u4ee3\u8868\u80cc\u666f\u57f7\u884c\n    D \u4ee3\u8868\u52d5\u614bproxy\uff0c\u4f7f\u75287777 port \n\nex. \n    java -DsocksProxyHost=localhost -DsocksProxyPort=7777\n    java \u57f7\u884c\u6642\u53ef\u4ee5\u52a0\u4e0a\u9019\u6bb5\u6307\u4ee4\uff0c\u5c31\u50cf\u662f\u5728\u9060\u7aef\u6a5f\u5668\u4e0a\u57f7\u884c\u610f\u601d\u4e00\u6a23\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7d9c\u5408\u4ee5\u4e0a\u5169\u8005\uff0c\u53ef\u4ee5\u5be6\u73fe\u9032\u5165\u5167\u90e8\u7db2\u8def\u57f7\u884c<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>\u5728\u9060\u7aef\u6a5f\u5668(192.168.10.2)\u4e0a\u5148\u57f7\u884c\nssh -D 9999 user@192.168.20.7\n\n\u5728\u672c\u6a5f\u4e0a\u57f7\u884c\nssh -L 9999:localhost:9999 quanto@192.168.10.2\n\n\u9019\u6a23\u5c31\u53ef\u4ee5\u8de8\u8d8a\u5169\u53f0(\u4ee5\u4e0a)\u6a5f\u5668\u9023\u5230\u5167\u90e8\u670d\u52d9<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u706b\u72d0\u8207proxy<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"736\" src=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.56.57.png\" alt=\"\" class=\"wp-image-105\" srcset=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.56.57.png 1020w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.56.57-300x216.png 300w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.56.57-150x108.png 150w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.56.57-768x554.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"358\" src=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.57.24.png\" alt=\"\" class=\"wp-image-106\" srcset=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.57.24.png 886w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.57.24-300x121.png 300w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.57.24-150x61.png 150w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.57.24-768x310.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linux\u4e5f\u53ef\u4ee5\u76f4\u63a5\u8a2d\u5b9aproxy<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"948\" height=\"220\" src=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.58.25.png\" alt=\"\" class=\"wp-image-107\" srcset=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.58.25.png 948w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.58.25-300x70.png 300w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.58.25-150x35.png 150w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53485.58.25-768x178.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Eclipse \u8a2d\u5b9a java \u57f7\u884c\u6642\u7684\u53c3\u6578<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">1. \u57f7\u884c\u6642\uff0c\u9078\u64c7 Run Configurations\u2026\n2. \u5728Java Application \u9078\u64c7\u8a72\u5c08\u6848\n3. \u5728Arguments \u7684 VM \u53c3\u6578\u7684\u90e8\u5206 \u52a0\u5165\"-DsocksProxyHost=localhost -DsocksProxyPort=7777\"\n4. Apply\n5. Run<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"742\" height=\"246\" src=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.01.40.png\" alt=\"\" class=\"wp-image-111\" srcset=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.01.40.png 742w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.01.40-300x99.png 300w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.01.40-150x50.png 150w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1662\" height=\"752\" src=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.03.01.png\" alt=\"\" class=\"wp-image-112\" srcset=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.03.01.png 1662w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.03.01-300x136.png 300w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.03.01-150x68.png 150w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.03.01-768x347.png 768w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2023\/10\/\u622a\u5716-2023-10-13-\u4e0b\u53486.03.01-1536x695.png 1536w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53e6\u5916\u4e5f\u53ef\u4ee5\u62ff\u4f86\u7576\u4f5cVPN\u4f7f\u7528<\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/wiki.archlinux.org\/title\/VPN_over_SSH\">https:\/\/wiki.archlinux.org\/title\/VPN_over_SSH<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>jconsole \u4e5f\u53ef\u4ee5\u5728\u672c\u6a5f\u76e3\u770b\u9060\u7aefjava<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>\u5728\u5efa\u7acb\u597d\u901a\u9053\u7684\u672c\u6a5f\ncd \/usr\/bin \n.\/jconsole -J-DsocksProxyHost=localhost -J-DsocksProxyPort=7777 service:jmx:rmi:\/\/\/jndi\/ rmi:\/\/192.168.20.7:9988\/jmxrmi -J-DsocksNonProxyHosts=\n\n\u53e6\u5916 java \u672c\u8eab\u4e5f\u8981\u8a2d\u5b9a\u6210\u53ef\u4ee5\u88ab\u76e3\u770b\uff0c\u57f7\u884c\u6642\u8981\u52a0\u5165\u4e00\u4e9b\u8a2d\u5b9a\uff0c\u5982\u4e0b\njava  -Xmx512M -Djava.rmi.server.hostname=192.168.20.7 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9988 -Dcom.sun.management.jmxremote.rmi.port=9989 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dsun.zip.disableMemoryMapping=true -jar $server\/$jar  &amp;\n\n\u4e0a\u8ff0\u7684\u4f8b\u5b50\u7528\u4e86\u5169\u500bport\uff0c\u5be6\u969b\u6e2c\u8a66\u53ea\u9700\u8981-Dcom.sun.management.jmxremote.port=9988 \u5373\u53ef\uff0c9989 port \u975e\u5fc5\u8981\n\n\u9019\u500b\u4f8b\u5b50\u662f\u5728\u672c\u6a5f\uff0c\u7d93\u7531proxy \u76e3\u770b\u5728\u7b2c\u4e8c\u5c64\u958b\u555f\u7684java \u904b\u4f5c\u60c5\u6cc1\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SSH Tunnel\u662f\u57fa\u65bcSSH \u7684\u4e00\u7a2e\u61c9\u7528\u65b9\u5f0f\uff0c\u53ef\u5728\u5169\u500bserver\u9593\u5efa\u7acb\u5b89\u5168\u7684\u901a\u9053\u5206\u5169\u7a2e\u61c9\u7528\u65b9\u5f0f<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[301,8,20,302,18,300,17,19],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-technology","tag-dsocksproxyport","tag-java","tag-jconsole","tag-jmxremote","tag-proxy","tag-ssh-proxy","tag-ssh-tunnel","tag-ssh"],"_links":{"self":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=104"}],"version-history":[{"count":8,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":2000,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions\/2000"}],"wp:attachment":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}