{"id":6164,"date":"2014-03-10T21:41:24","date_gmt":"2014-03-10T13:41:24","guid":{"rendered":"http:\/\/jpuyy.com\/?p=6164"},"modified":"2020-04-07T14:01:39","modified_gmt":"2020-04-07T06:01:39","slug":"ssh","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=6164","title":{"rendered":"ssh\u7aef\u53e3\u8f6c\u53d1"},"content":{"rendered":"<p>\u5f88\u591a\u65f6\u5019\u670d\u52a1\u5668\u96c6\u7fa4\u662f\u6709\u8df3\u677f\u673a\uff0c\u8fdc\u7a0b\u8fdb\u884c\u4efb\u4f55\u64cd\u4f5c\u7684\u65f6\u5019\u90fd\u662f\u5148\u767b\u9646\u8df3\u677f\u673a\uff0c\u518d\u767b\u9646\u5185\u7f51\u7684\u673a\u5668\u3002<\/p>\n<p>\u6211\u4eec\u628a\u672c\u673a\u53eb\u505alocal\uff0c\u8df3\u677f\u673a\u53eb\u505atiaoban\uff0c\u771f\u6b63\u8981\u8fde\u63a5\u7684\u96c6\u7fa4\u5185\u7684\u670d\u52a1\u5668\u53eb\u505anode1\u3002\u5982\u4f55\u5feb\u901f\u4ecelocal\u767b\u9646\u5230node1? \u64cd\u4f5c\u5982\u4e0b\uff1a<\/p>\n<p>\u65b9\u6cd5\u4e00\uff1a<\/p>\n<p>1. \u5728 tiaoban \u4e0a\u8f93\u5165\u5982\u4e0b\u547d\u4ee4<\/p>\n<pre> ssh -CfNg -L 3333:node1:22 root@node1<\/pre>\n<p>-L\u8868\u793alocal\uff0c\u5373\u5728\u8df3\u677f\u673a\u4e0a\u5f00\u8bbe\u4e00\u4e2a3333\u7684\u7aef\u53e3\uff0c\u4fdd\u8bc1\u6709ssh\u8fde\u63a5\u52303333\u65f6\uff0c\u8f6c\u53d1\u5230node1\u768422\u7aef\u53e3\u3002<\/p>\n<p>\u7136\u540e\u5728local\u53bb\u8fde\u8df3\u677f\u673a\u76843333\u7aef\u53e3<\/p>\n<pre>ssh -p 3333 root@tiaoban<\/pre>\n<p>\u6ce8\u610f\uff0c\u4e0a\u9762\u6211\u90fd\u7528\u7684\u662froot\u3002\u5b9e\u9645\u662fnode1\u7684\u7528\u6237\u662f\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u76f4\u63a5\u767b\u9646\u5230\u673a\u5668node1\u4e86\u3002<\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4f1a\u5728\u8df3\u677f\u673a\u4e0a\u6253\u5f003333\u7aef\u53e3\uff0c\u66b4\u9732\u4e86\u7aef\u53e3\u3002<\/p>\n<p>\u65b9\u6cd5\u4e8c\uff1a\u901a\u8fc7proxycommand \u548c netcat<\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u9700\u8981\u5bf9tiaoban\u548cnode1\u8fdb\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u53ea\u9700\u5728local\u673a\u5668\u7684ssh_config(\u6216\u662f~\/.ssh\/config)\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e<\/p>\n<pre>Host node1\nHostName node1\nPort 22\nProxyCommand ssh -p 3333 root@tiaoban ; nc %h %p<\/pre>\n<p>\u7136\u540e\u5728local\u8f93\u5165<\/p>\n<pre>ssh root@node1<\/pre>\n<p>\u8fd9\u6837\u53ef\u76f4\u63a5\u8f6c\u53d1\uff0cnc\u7684\u4f5c\u7528\u662f\u505a\u4e00\u4e2atunnel\uff0c\u5728\u8df3\u677f\u673a\u4e0a\u4e0d\u4f1a\u66b4\u9732\u7aef\u53e3\u3002<\/p>\n<p>\u5e94\u7528\uff1a\u5728\u672c\u5730\u542f\u4e00\u4e2a socks5 \u4ee3\u7406<\/p>\n<p>ssh -D 1081 jpuyy@yyhome -p 22<\/p>\n<p>\u5728\u5916\u9762\u8fde\u63a5\u5bb6\u91cc\u7684\u8def\u7531\u5668\u754c\u9762<\/p>\n<pre>ssh -L 8989:192.168.1.1:80 jpuyy@yyhome.dns.com\n# \u6d4f\u89c8\u5668\u6253\u5f00 127.0.0.1:8989 \u5373\u53ef\u7ba1\u7406\u8def\u7531\u5668\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u591a\u65f6\u5019\u670d\u52a1\u5668\u96c6\u7fa4\u662f\u6709\u8df3\u677f\u673a\uff0c\u8fdc\u7a0b\u8fdb\u884c\u4efb\u4f55\u64cd\u4f5c\u7684\u65f6\u5019\u90fd\u662f\u5148\u767b\u9646\u8df3\u677f\u673a\uff0c\u518d\u767b\u9646\u5185\u7f51\u7684\u673a\u5668\u3002 \u6211\u4eec\u628a\u672c\u673a\u53eb\u505alocal\uff0c\u8df3\u677f\u673a\u53eb\u505atiaoban\uff0c\u771f\u6b63\u8981\u8fde\u63a5\u7684\u96c6\u7fa4\u5185\u7684\u670d\u52a1\u5668\u53eb\u505anode1\u3002\u5982\u4f55\u5feb\u901f\u4ecelocal\u767b\u9646\u5230node1? \u64cd\u4f5c\u5982\u4e0b\uff1a \u65b9\u6cd5\u4e00\uff1a 1. \u5728 tiaoban \u4e0a\u8f93\u5165\u5982\u4e0b\u547d\u4ee4 ssh -CfNg -L 3333:node1:22 root@node1 -L\u8868\u793alocal\uff0c\u5373\u5728\u8df3\u677f\u673a\u4e0a\u5f00\u8bbe\u4e00\u4e2a3333\u7684\u7aef\u53e3\uff0c\u4fdd\u8bc1\u6709ssh\u8fde\u63a5\u52303333\u65f6\uff0c\u8f6c\u53d1\u5230node1\u768422\u7aef\u53e3\u3002 \u7136\u540e\u5728local\u53bb\u8fde\u8df3\u677f\u673a\u76843333\u7aef\u53e3 ssh -p 3333 root@tiaoban \u6ce8\u610f\uff0c\u4e0a\u9762\u6211\u90fd\u7528\u7684\u662froot\u3002\u5b9e\u9645\u662fnode1\u7684\u7528\u6237\u662f\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u76f4\u63a5\u767b\u9646\u5230\u673a\u5668node1\u4e86\u3002 \u8fd9\u79cd\u65b9\u6cd5\u4f1a\u5728\u8df3\u677f\u673a\u4e0a\u6253\u5f003333\u7aef\u53e3\uff0c\u66b4\u9732\u4e86\u7aef\u53e3\u3002 \u65b9\u6cd5\u4e8c\uff1a\u901a\u8fc7proxycommand \u548c netcat \u8fd9\u79cd\u65b9\u6cd5\u4e0d\u9700\u8981\u5bf9tiaoban\u548cnode1\u8fdb\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u53ea\u9700\u5728local\u673a\u5668\u7684ssh_config(\u6216\u662f~\/.ssh\/config)\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e Host node1 HostName node1 Port 22 ProxyCommand ssh -p 3333 root@tiaoban ; nc %h %p \u7136\u540e\u5728local\u8f93\u5165 ssh root@node1 \u8fd9\u6837\u53ef\u76f4\u63a5\u8f6c\u53d1\uff0cnc\u7684\u4f5c\u7528\u662f\u505a\u4e00\u4e2atunnel\uff0c\u5728\u8df3\u677f\u673a\u4e0a\u4e0d\u4f1a\u66b4\u9732\u7aef\u53e3\u3002 \u5e94\u7528\uff1a\u5728\u672c\u5730\u542f\u4e00\u4e2a socks5 \u4ee3\u7406 ssh -D 1081 jpuyy@yyhome -p 22 \u5728\u5916\u9762\u8fde\u63a5\u5bb6\u91cc\u7684\u8def\u7531\u5668\u754c\u9762 ssh [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-6164","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6164"}],"version-history":[{"count":7,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6164\/revisions"}],"predecessor-version":[{"id":8815,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6164\/revisions\/8815"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}