{"id":1712,"date":"2023-03-26T07:24:34","date_gmt":"2023-03-25T23:24:34","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1712"},"modified":"2023-04-23T21:39:28","modified_gmt":"2023-04-23T13:39:28","slug":"ssh-settings-connect-to-remote-hosts-through-http-proxy","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/26\/ssh-settings-connect-to-remote-hosts-through-http-proxy\/","title":{"rendered":"ssh\u8bbe\u7f6e\u901a\u8fc7http\u4ee3\u7406\u8fde\u63a5\u8fdc\u7a0b\u4e3b\u673a"},"content":{"rendered":"<h2>\u9700\u6c42\u80cc\u666f<\/h2>\n<p>\u5b58\u5728A B C\u4e09\u53f0\u4e3b\u673a\uff0c\u7531\u4e8e\u5b89\u5168\u56e0\u7d20\u6216\u8005\u5176\u4ed6\uff08\u4e91\u670d\u52a1\u5668\u672a\u7ed1\u5b9a\u5f39\u6027IP\u7b49\uff09\uff0cA\u4e0d\u80fd\u76f4\u63a5\u4e0eC\u901a\u4fe1\u3002\u4f46\u662f\u5b58\u5728B\u53ef\u4ee5\u4e0eA,C\u901a\u4fe1\u3002\u5219\u73b0\u5728\u9700\u8981\u5728A\u4e0a\u901a\u8fc7ssh\u8fdc\u7a0b\u8bbf\u95eeC\uff0c\u5047\u8bbeB\u5df2\u7ecf\u642d\u5efa\u597d\u4e00\u4e2ahttp\u4ee3\u7406\uff0c\u4fbf\u53ef\u5229\u7528http\u4ee3\u7406ssh\u8bbf\u95eeC\u7684\u670d\u52a1\u3002\u5177\u4f53\u65b9\u6cd5\u5206\u4e3a2\u79cd\u5e38\u89c1\u505a\u6cd5\uff1a<\/p>\n<p><!-- more --><\/p>\n<ul>\n<li>1.\u901a\u8fc7\u8f6f\u4ef6<code>corkscrew<\/code>\u4f5c\u4e3aproxy\u7684\u5ba2\u6237\u7aef<\/li>\n<li>2.\u901a\u8fc7<code>ncat<\/code>\u4f5c\u4e3aproxy\u7684\u5ba2\u6237\u7aef<\/li>\n<\/ul>\n<p>\u4e0d\u8fc7\u6700\u7ec8\u672c\u8d28\u662f\u4e00\u6837\u7684\uff0cssh\u901a\u8fc7\u547d\u4ee4<code>ssh -o ProxyCommand=&quot;xxx&quot;<\/code>\u7684\u5f62\u5f0f\u8bbe\u7f6e\u4ee3\u7406\u4fe1\u606f\uff0c\u5373\u53ef\u4f7f\u7528\uff0c\u8fc7\u7a0b\u662f\u5bf9\u7528\u6237\u900f\u660e\u65e0\u611f\u7684\u3002<\/p>\n<h2>corkscrew<\/h2>\n<p>\u5b98\u7f51: <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/pkgs.org\/download\/corkscrew\">https:\/\/pkgs.org\/download\/corkscrew<\/a><\/p>\n<pre><code class=\"language-bash\">ssh root@{$host_name} -p 22 -o ProxyCommand=&quot;corkscrew ${host} ${port} %h %p&quot; -o IdentityFile=key\u7684\u7edd\u5bf9\u8def\u5f84<\/code><\/pre>\n<p>\u4e3e\u4f8b: A\u4e3b\u673a\u4e0a\u8bbe\u7f6e\u901a\u8fc7B\u4e3b\u673a\u4f5c\u4e3aproxy\u8fde\u63a5C\u4e3b\u673a<\/p>\n<pre><code class=\"language-bash\">ssh root@C -p 22 -o ProxyCommand=&quot;corkscrew B 30080 %h %p&quot; -o IdentityFile=key\u7684\u7edd\u5bf9\u8def\u5f84<\/code><\/pre>\n<h2>ncat<\/h2>\n<pre><code class=\"language-bash\">yum install nmap-ncat  #\u5b89\u88c5ncat\u8f6f\u4ef6<\/code><\/pre>\n<pre><code class=\"language-bash\">ssh root@{$host_name} -p 22 -o ProxyCommand=&quot;ncat --proxy-type http --proxy ${host}:${port} %h %p&quot; -o IdentityFile=key\u7684\u7edd\u5bf9\u8def\u5f84<\/code><\/pre>\n<h2>\u4e3e\u4f8b: A\u4e3b\u673a\u4e0a\u8bbe\u7f6e\u901a\u8fc7B\u4e3b\u673a\u4f5c\u4e3aproxy\u8fde\u63a5C\u4e3b\u673a<\/h2>\n<pre><code class=\"language-bash\">ssh root@C -p 22 -o ProxyCommand=&quot;ncat --proxy-type http --proxy B:30080 %h %p&quot; -o IdentityFile=key\u7684\u7edd\u5bf9\u8def\u5f84<\/code><\/pre>\n<pre><code class=\"language-bash\">ssh yezhou@118.220.32.208 -p 22 -o ProxyCommand=&quot;ncat --proxy-type http --proxy 192.168.0.8:8118 %h %p&quot; -o IdentityFile=\/root\/.ssh\/id_rsa<\/code><\/pre>\n<h2>\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h2>\n<p>\u901a\u8fc7proxy\u7684\u5f62\u5f0f\u8fde\u63a5ssh\uff0c\u5176\u5b9e\u5927\u90e8\u5206\u4eba\u4f1a\u9047\u5230\u4e00\u4e2a\u4e25\u91cd\u7684\u95ee\u9898\u3002\u90a3\u5c31\u662fssh\u8fde\u63a5\u5f88\u5361\uff0c\u5076\u5c14\u80fd\u76f4\u63a5\u8fde\u63a5\uff0c\u5076\u5c14\u5c31\u5361\u7740\u4e0d\u52a8\u3002\u90a3\u662f\u4e3a\u4f55? \u5f88\u7b80\u5355<code>ssh -v<\/code>\u52a0\u4e0a<code>-v<\/code>\u53c2\u6570\uff0c\u6253\u51fadebug\u65e5\u5fd7\u4fe1\u606f\u67e5\u660e\u539f\u56e0\u5373\u53ef\u3002\u5047\u5982\u5361\u5728\u6700\u540e\u4e00\u6761\u63d0\u793a\u4fe1\u606f\uff1a<code>expecting SSH2_MSG_KEX_ECDH_REPLY<\/code> \u7c7b\u4f3c\u8fd9\u6837\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u5c1d\u8bd5\u4fee\u6539eth0\u7f51\u5361\u7684MTU\u503c\uff1a<\/p>\n<pre><code class=\"language-bash\"># echo &quot;1420&quot; &gt; \/sys\/class\/net\/eth0\/mtu\n# systemctl restart network<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u6c42\u80cc\u666f \u5b58\u5728A B C\u4e09\u53f0\u4e3b\u673a\uff0c\u7531\u4e8e\u5b89\u5168\u56e0\u7d20\u6216\u8005\u5176\u4ed6\uff08\u4e91\u670d\u52a1\u5668\u672a\u7ed1\u5b9a\u5f39\u6027IP\u7b49\uff09\uff0cA\u4e0d\u80fd\u76f4\u63a5\u4e0eC\u901a\u4fe1\u3002\u4f46\u662f\u5b58 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[96,142],"class_list":["post-1712","post","type-post","status-publish","format-standard","hentry","category-devops-base","tag-ssh","tag-142"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1712"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1712\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}