{"id":85443,"date":"2023-12-17T13:55:25","date_gmt":"2023-12-17T05:55:25","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=85443"},"modified":"2023-12-17T13:55:25","modified_gmt":"2023-12-17T05:55:25","slug":"ssh-port-forward","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ssh-port-forward.html","title":{"rendered":"\u901a\u8fc7 SSH \u5b9e\u73b0 TCP \/ IP \u96a7\u9053\uff08\u7aef\u53e3\u8f6c\u53d1\uff09"},"content":{"rendered":"
\u5bf9\u4e8e Secure Shell (SSH)<\/a>[1]<\/span> \u8fd9\u6837\u7684\u7f51\u7edc\u534f\u8bae\u6765\u8bf4\uff0c\u5176\u4e3b\u8981\u804c\u8d23\u5c31\u662f\u5728\u7ec8\u7aef\u6a21\u5f0f\u4e0b\u8bbf\u95ee\u4e00\u4e2a\u8fdc\u7a0b\u7cfb\u7edf\u3002\u56e0\u4e3a SSH \u534f\u8bae\u5bf9\u4f20\u8f93\u6570\u636e\u8fdb\u884c\u4e86\u52a0\u5bc6\uff0c\u6240\u4ee5\u901a\u8fc7\u5b83\u5728\u8fdc\u7aef\u7cfb\u7edf\u6267\u884c\u547d\u4ee4\u662f\u5b89\u5168\u7684\u3002\u6b64\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728\u8fd9\u79cd\u52a0\u5bc6\u540e\u7684\u8fde\u63a5\u4e0a\u901a\u8fc7\u521b\u5efa\u96a7\u9053\uff08\u7aef\u53e3\u8f6c\u53d1\uff09\u7684\u65b9\u5f0f\uff0c\u6765\u5b9e\u73b0\u4e24\u4e2a\u4e0d\u540c\u7ec8\u7aef\u95f4\u7684\u4e92\u8054\u3002\u51ed\u501f\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ea\u8981\u6211\u4eec\u80fd\u901a\u8fc7 SSH \u521b\u5efa\u8fde\u63a5\uff0c\u5c31\u53ef\u4ee5\u7ed5\u5f00\u9632\u706b\u5899\u6216\u8005\u7aef\u53e3\u7981\u7528\u7684\u9650\u5236\u3002<\/p>\n \u8fd9\u4e2a\u8bdd\u9898\u5728\u7f51\u7edc\u9886\u57df\u6709\u5927\u91cf\u7684\u5e94\u7528\u548c\u8ba8\u8bba\uff1a<\/p>\n \u6211\u4eec\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\u5e76\u4e0d\u8ba8\u8bba\u7aef\u53e3\u8f6c\u53d1\u7684\u7ec6\u8282\uff0c\u800c\u662f\u51c6\u5907\u4ecb\u7ecd\u4e00\u4e2a\u5982\u4f55\u4f7f\u7528 OpenSSH<\/a>[8]<\/span> \u6765\u5b8c\u6210 TCP \u7aef\u53e3\u8f6c\u53d1\u7684\u901f\u67e5\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u516b\u79cd\u5e38\u89c1\u7684\u573a\u666f\u3002\u6709\u4e9b SSH \u5ba2\u6237\u7aef\uff0c\u6bd4\u5982 PuTTY<\/a>[9]<\/span>\uff0c\u4e5f\u5141\u8bb8\u901a\u8fc7\u754c\u9762\u914d\u7f6e\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u7aef\u53e3\u8f6c\u53d1\u3002\u800c\u6211\u4eec\u7740\u91cd\u5173\u6ce8\u7684\u662f\u901a\u8fc7 OpenSSH \u6765\u5b9e\u73b0\u7684\u7684\u65b9\u5f0f\u3002<\/p>\n \u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u5f53\u4e2d\uff0c\u6211\u4eec\u5047\u8bbe\u73af\u5883\u4e2d\u7684\u7f51\u7edc\u5212\u5206\u4e3a\u5916\u90e8\u7f51\u7edc\uff08network1\uff09\u548c\u5185\u90e8\u7f51\u7edc\uff08network2\uff09\u4e24\u90e8\u5206\uff0c\u5e76\u4e14\u8fd9\u4e24\u4e2a\u7f51\u7edc\u4e4b\u95f4\uff0c\u53ea\u80fd\u5728 externo1 \u4e0e interno1 \u4e4b\u95f4\u901a\u8fc7 SSH \u8fde\u63a5\u7684\u65b9\u5f0f\u6765\u4e92\u76f8\u8bbf\u95ee\u3002\u5916\u90e8\u7f51\u7edc\u7684\u8282\u70b9\u4e4b\u95f4\u548c\u5185\u90e8\u7f51\u7edc\u7684\u8282\u70b9\u4e4b\u95f4\u662f\u5b8c\u5168\u8054\u901a\u7684\u3002<\/p>\n <\/p>\n \u5728 externo1 \u8282\u70b9\u8bbf\u95ee\u7531 interno1 \u8282\u70b9\u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u672c\u5730\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 = localhost \/ \u4e3b\u673a = localhost \uff09<\/p><\/blockquote>\n externo1 \u8282\u70b9\u53ef\u4ee5\u901a\u8fc7 OpenSSH \u8fde\u63a5\u5230 interno1 \u8282\u70b9\uff0c\u4e4b\u540e\u6211\u4eec\u60f3\u901a\u8fc7\u5176\u8bbf\u95ee\u8fd0\u884c\u5728 5900 \u7aef\u53e3\u4e0a\u7684 VNC \u670d\u52a1\u3002<\/p>\n <\/p>\n \u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u6765\u5b9e\u73b0\uff1a<\/p>\n \u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 externo1 \u8282\u70b9\u4e0a\u786e\u8ba4\u4e0b 7900 \u7aef\u53e3\u662f\u5426\u5904\u4e8e\u76d1\u542c\u72b6\u6001\u4e2d\uff1a<\/p>\n \u6211\u4eec\u53ea\u9700\u8981\u5728 externo1 \u8282\u70b9\u4e0a\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u5373\u53ef\u8bbf\u95ee internal \u8282\u70b9\u7684 VNC \u670d\u52a1\uff1a<\/p>\n \u6ce8\u610f\uff1a\u5728 vncviewer \u7684 man \u624b\u518c<\/a>[10]<\/span>\u4e2d\u5e76\u672a\u63d0\u53ca\u8fd9\u79cd\u4fee\u6539\u7aef\u53e3\u53f7\u7684\u65b9\u5f0f\u3002\u5728 About VNCViewer configuration of the output TCP port<\/a>[11]<\/span> \u4e2d\u53ef\u4ee5\u770b\u5230\u3002\u8fd9\u4e5f\u662f the TightVNC vncviewer<\/a>[12]<\/span> \u6240\u4ecb\u7ecd\u7684\u7684\u3002<\/p>\n \u5728 externo2 \u8282\u70b9\u4e0a\u8bbf\u95ee\u7531 interno1 \u8282\u70b9\u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u672c\u5730\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 = 0.0.0.0 \/ \u4e3b\u673a = localhost\uff09<\/p><\/blockquote>\n \u8fd9\u6b21\u7684\u573a\u666f\u8ddf\u65b9\u6848 1 \u7684\u573a\u666f\u7684\u7c7b\u4f3c\uff0c\u4f46\u662f\u6211\u4eec\u8fd9\u6b21\u60f3\u4ece externo2 \u8282\u70b9\u6765\u8fde\u63a5\u5230 interno1 \u4e0a\u7684 VNC \u670d\u52a1\uff1a<\/p>\n <\/p>\n \u6b63\u786e\u7684\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n \u770b\u8d77\u6765\u8ddf\u65b9\u6848 1 \u4e2d\u7684\u547d\u4ee4\u7c7b\u4f3c\uff0c\u4f46\u662f\u8ba9\u6211\u4eec\u770b\u770b netstat<\/span> \u547d\u4ee4\u7684\u8f93\u51fa\u4e0a\u7684\u533a\u522b\u30027900 \u7aef\u53e3\u88ab\u7ed1\u5b9a\u5230\u4e86\u672c\u5730\uff08127.0.0.1<\/span>\uff09\uff0c\u6240\u4ee5\u53ea\u6709\u672c\u5730\u8fdb\u7a0b\u53ef\u4ee5\u8bbf\u95ee\u3002\u8fd9\u6b21\u6211\u4eec\u5c06\u7aef\u53e3\u5173\u8054\u5230\u4e86 0.0.0.0<\/span>\uff0c\u6240\u4ee5\u7cfb\u7edf\u5141\u8bb8\u4efb\u4f55 IP \u5730\u5740\u7684\u673a\u5668\u8bbf\u95ee 7900 \u8fd9\u4e2a\u7aef\u53e3\u3002<\/p>\n \u6240\u4ee5\u73b0\u5728\u5728 externo2 \u8282\u70b9\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u6267\u884c\uff1a<\/p>\n \u6765\u8fde\u63a5\u5230 interno1 \u8282\u70b9\u4e0a\u7684 VNC \u670d\u52a1\u3002<\/p>\n \u9664\u4e86\u5c06 IP \u6307\u5b9a\u4e3a 0.0.0.0<\/span> \u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u53c2\u6570 -g<\/span>\uff08\u5141\u8bb8\u8fdc\u7a0b\u673a\u5668\u4f7f\u7528\u672c\u5730\u7aef\u53e3\u8f6c\u53d1\uff09\uff0c\u5b8c\u6574\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n \u8fd9\u6761\u547d\u4ee4\u4e0e\u524d\u9762\u7684\u547d\u4ee4\u80fd\u5b9e\u73b0\u76f8\u540c\u6548\u679c\uff1a<\/p>\n \u6362\u53e5\u8bdd\u8bf4\uff0c\u5982\u679c\u6211\u4eec\u60f3\u9650\u5236\u53ea\u80fd\u8fde\u63a5\u5230\u7cfb\u7edf\u4e0a\u7684\u67d0\u4e2a IP\uff0c\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u5b9a\u4e49\uff1a<\/p>\n \u5728 interno1 \u4e0a\u8bbf\u95ee\u7531 externo1 \u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u8fdc\u7a0b\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 = localhost \/ \u4e3b\u673a = localhost\uff09<\/p><\/blockquote>\n \u5728\u573a\u666f 1 \u4e2d SSH \u670d\u52a1\u5668\u4e0e TCP \u670d\u52a1\uff08VNC\uff09\u63d0\u4f9b\u8005\u5728\u540c\u4e00\u4e2a\u8282\u70b9\u4e0a\u3002\u73b0\u5728\u6211\u4eec\u60f3\u5728 SSH \u5ba2\u6237\u7aef\u6240\u5728\u7684\u8282\u70b9\u4e0a\uff0c\u63d0\u4f9b\u4e00\u4e2a TCP \u670d\u52a1\uff08VNC\uff09\u4f9b SSH \u670d\u52a1\u7aef\u6765\u8bbf\u95ee\uff1a<\/p>\n <\/p>\n \u5c06\u65b9\u6848 1 \u4e2d\u7684\u547d\u4ee4\u53c2\u6570\u7531 -L<\/span> \u66ff\u6362\u4e3a -R<\/span>\u3002<\/p>\n \u5b8c\u6574\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n \u7136\u540e\u6211\u4eec\u5c31\u80fd\u770b\u5230 interno1 \u8282\u70b9\u4e0a\u5bf9 7900 \u7aef\u53e3\u6b63\u5728\u76d1\u542c\uff1a<\/p>\n \u73b0\u5728\u5728 interno1 \u8282\u70b9\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u8bbf\u95ee externo1 \u4e0a\u7684 VNC \u670d\u52a1\uff1a<\/p>\n interno2 \u4f7f\u7528 externo1 \u4e0a\u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u8fdc\u7aef\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 = 0.0.0.0 \/ \u4e3b\u673a = localhost\uff09<\/p><\/blockquote>\n \u4e0e\u573a\u666f 3 \u7c7b\u4f3c\uff0c\u4f46\u662f\u73b0\u5728\u6211\u4eec\u5c1d\u8bd5\u6307\u5b9a\u5141\u8bb8\u8bbf\u95ee\u8f6c\u53d1\u7aef\u53e3\u7684 IP\uff08\u5c31\u50cf\u573a\u666f 2 \u4e2d\u505a\u7684\u4e00\u6837\uff09\u4e3a 0.0.0.0<\/span>\uff0c\u8fd9\u6837\u5176\u4ed6\u8282\u70b9\u4e5f\u53ef\u4ee5\u8bbf\u95ee VNC \u670d\u52a1\uff1a<\/p>\n <\/p>\n \u6b63\u786e\u7684\u547d\u4ee4\u662f\uff1a<\/p>\n \u4f46\u662f\u8fd9\u91cc\u6709\u4e2a\u91cd\u70b9\u9700\u8981\u4e86\u89e3\uff0c\u51fa\u4e8e\u5b89\u5168\u7684\u539f\u56e0\uff0c\u5982\u679c\u6211\u4eec\u76f4\u63a5\u6267\u884c\u8be5\u547d\u4ee4\u7684\u8bdd\u53ef\u80fd\u4e0d\u4f1a\u751f\u6548\uff0c\u56e0\u4e3a\u6211\u4eec\u9700\u8981\u4fee\u6539 SSH \u670d\u52a1\u7aef\u7684\u4e00\u4e2a\u53c2\u6570\u503c GatewayPorts<\/span>\uff0c\u5b83\u7684\u9ed8\u8ba4\u503c\u662f\uff1ano<\/span>\u3002<\/p>\n GatewayPorts<\/p>\n \u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u8fdc\u7a0b\u4e3b\u673a\u662f\u5426\u5141\u8bb8\u5ba2\u6237\u7aef\u8bbf\u95ee\u8f6c\u53d1\u7aef\u53e3\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0csshd(8) \u53ea\u5141\u8bb8\u672c\u673a\u8fdb\u7a0b\u8bbf\u95ee\u8f6c\u53d1\u7aef\u53e3\u3002\u8fd9\u662f\u4e3a\u4e86\u963b\u6b62\u5176\u4ed6\u4e3b\u673a\u8fde\u63a5\u5230\u8be5\u8f6c\u53d1\u7aef\u53e3\u3002GatewayPorts \u53c2\u6570\u53ef\u7528\u4e8e\u8ba9 sshd \u5141\u8bb8\u8fdc\u7a0b\u8f6c\u53d1\u7aef\u53e3\u7ed1\u5b9a\u5230\u975e\u56de\u73af\u5730\u5740\u4e0a\uff0c\u4ece\u800c\u53ef\u4ee5\u8ba9\u8fdc\u7a0b\u4e3b\u673a\u8bbf\u95ee\u3002\u5f53\u53c2\u6570\u503c\u8bbe\u7f6e\u4e3a \u201cno\u201d \u7684\u65f6\u5019\u53ea\u6709\u672c\u673a\u53ef\u4ee5\u8bbf\u95ee\u8f6c\u53d1\u7aef\u53e3\uff1b\u201cyes\u201d \u5219\u8868\u793a\u5141\u8bb8\u8fdc\u7a0b\u8f6c\u53d1\u7aef\u53e3\u7ed1\u5b9a\u5230\u901a\u914d\u5730\u5740\u4e0a\uff1b\u6216\u8005\u8bbe\u7f6e\u4e3a \u201cclientspecified\u201d \u5219\u8868\u793a\u7531\u5ba2\u6237\u7aef\u6765\u9009\u62e9\u54ea\u4e9b\u4e3b\u673a\u5730\u5740\u5141\u8bb8\u8bbf\u95ee\u8f6c\u53d1\u7aef\u53e3\u3002\u9ed8\u8ba4\u503c\u662f \u201cno\u201d\u3002<\/p><\/blockquote>\n \u5982\u679c\u6211\u4eec\u6ca1\u6709\u4fee\u6539\u670d\u52a1\u5668\u914d\u7f6e\u7684\u6743\u9650\uff0c\u6211\u4eec\u5c06\u4e0d\u80fd\u4f7f\u7528\u8be5\u65b9\u6848\u6765\u8fdb\u884c\u7aef\u53e3\u8f6c\u53d1\u3002\u8fd9\u662f\u56e0\u4e3a\u5982\u679c\u6ca1\u6709\u5176\u4ed6\u7684\u9650\u5236\uff0c\u7528\u6237\u53ef\u4ee5\u5f00\u542f\u4e00\u4e2a\u7aef\u53e3\uff08> 1024\uff09\u6765\u76d1\u542c\u6765\u81ea\u5916\u90e8\u7684\u8bf7\u6c42\u5e76\u8f6c\u53d1\u5230 localhost:7900<\/span>\u3002<\/p>\n \u53c2\u7167\u8fd9\u4e2a\u6848\u4f8b\uff1anetcat<\/a>[13]<\/span>\u00a0(\u00a0Debian # 310431: sshd_config should warn about the GatewayPorts workaround.<\/a>[14]<\/span>\u00a0)<\/p>\n \u6240\u4ee5\u6211\u4eec\u4fee\u6539 \/etc\/ssh\/sshd_config<\/span>\uff0c\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n \u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u91cd\u8f7d\u4fee\u6539\u540e\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u5728 Debian \u548c Ubuntu \u4e0a\uff09\u3002<\/p>\n \u6211\u4eec\u786e\u8ba4\u4e00\u4e0b\u73b0\u5728 interno1 \u8282\u70b9\u4e0a\u5b58\u5728 7900 \u7aef\u53e3\u7684\u76d1\u542c\u7a0b\u5e8f\uff0c\u76d1\u542c\u6765\u81ea\u4e0d\u540c IP \u7684\u8bf7\u6c42\uff1a<\/p>\n \u7136\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u5728 interno2 \u8282\u70b9\u4e0a\u4f7f\u7528 VNC \u670d\u52a1\u4e86\uff1a<\/p>\n \u5728 externo1 \u4e0a\u4f7f\u7528\u7531 interno2 \u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u672c\u5730\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 localhost \/ \u4e3b\u673a = interno2 \uff09<\/p><\/blockquote>\n <\/p>\n \u5728\u8fd9\u79cd\u573a\u666f\u4e0b\u6211\u4eec\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n \u7136\u540e\u6211\u4eec\u5c31\u80fd\u5728 externo1 \u8282\u70b9\u4e0a\uff0c\u901a\u8fc7\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u6765\u4f7f\u7528 VNC \u670d\u52a1\u4e86\uff1a<\/p>\n \u5728 interno1 \u4e0a\u4f7f\u7528\u7531 externo2 \u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u8fdc\u7a0b\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 = localhost \/ host = externo2\uff09<\/p><\/blockquote>\n <\/p>\n \u5728\u8fd9\u79cd\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n \u7136\u540e\u6211\u4eec\u53ef\u4ee5\u5728 interno1 \u4e0a\u901a\u8fc7\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u6765\u8bbf\u95ee VNC \u670d\u52a1\uff1a<\/p>\n \u5728 externo2 \u4e0a\u4f7f\u7528\u7531 interno2 \u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u672c\u5730\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 = 0.0.0.0 \/ \u4e3b\u673a = interno2\uff09<\/p><\/blockquote>\n <\/p>\n \u672c\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n \u6216\u8005\uff1a<\/p>\n \u7136\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u5728 externo2 \u4e0a\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u6765\u8bbf\u95ee vnc \u670d\u52a1\uff1a<\/p>\n \u5728 interno2 \u4e0a\u4f7f\u7528\u7531 externo2 \u63d0\u4f9b\u7684 TCP \u670d\u52a1\uff08\u8fdc\u7a0b\u7aef\u53e3\u8f6c\u53d1 \/ \u7ed1\u5b9a\u5730\u5740 = 0.0.0.0 \/ \u4e3b\u673a = externo2\uff09<\/p><\/blockquote>\n <\/p>\n \u672c\u573a\u666f\u4e0b\u6211\u4eec\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n SSH \u670d\u52a1\u5668\u9700\u8981\u914d\u7f6e\u4e3a\uff1a<\/p>\n \u5c31\u50cf\u6211\u4eec\u5728\u573a\u666f 4 \u4e2d\u8bb2\u8fc7\u7684\u90a3\u6837\u3002<\/p>\n \u7136\u540e\u6211\u4eec\u53ef\u4ee5\u5728 interno2 \u8282\u70b9\u4e0a\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u6765\u8bbf\u95ee VNC \u670d\u52a1\uff1a<\/p>\n \u5982\u679c\u6211\u4eec\u9700\u8981\u4e00\u6b21\u6027\u7684\u521b\u5efa\u591a\u4e2a\u96a7\u9053\uff0c\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u7684\u65b9\u5f0f\u66ff\u4ee3\u4e00\u4e2a\u53ef\u80fd\u5f88\u957f\u7684\u547d\u4ee4\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u9009\u62e9\u3002\u5047\u8bbe\u6211\u4eec\u53ea\u80fd\u901a\u8fc7 SSH \u7684\u65b9\u5f0f\u8bbf\u95ee\u67d0\u4e2a\u7279\u5b9a\u7f51\u7edc\uff0c\u540c\u65f6\u53c8\u9700\u8981\u521b\u5efa\u591a\u4e2a\u96a7\u9053\u6765\u8bbf\u95ee\u8be5\u7f51\u7edc\u5185\u4e0d\u540c\u670d\u52a1\u5668\u4e0a\u7684\u670d\u52a1\uff0c\u6bd4\u5982 VNC \u6216\u8005 \u8fdc\u7a0b\u684c\u9762<\/a>[15]<\/span>\u3002\u6b64\u65f6\u53ea\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u5982\u4e0b\u7684\u914d\u7f6e\u6587\u4ef6 $HOME\/redirects<\/span> \u5373\u53ef\uff08\u5728 SOCKS \u670d\u52a1\u5668 \u4e0a\uff09\u3002<\/p>\n \u7136\u540e\u6211\u4eec\u53ea\u9700\u8981\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n via: https:\/\/wesharethis.com\/2017\/07\/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh\/<\/a><\/p>\n \u4f5c\u8005\uff1aAhmad<\/a>[16]<\/span> \u8bd1\u8005\uff1atoutoudnf<\/a>[17]<\/span> \u6821\u5bf9\uff1awxy<\/a>[18]<\/span><\/p>\n \u672c\u6587\u7531 LCTT<\/a>[19]<\/span> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a>[20]<\/span> \u8363\u8a89\u63a8\u51fa<\/p>\n \u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-8945-1.html<\/a><\/p>\n\n
externo1 $ ssh -L 7900:localhost:5900 user@interno1 \r\n<\/pre>\n
externo1 $ netstat -ltn\r\nActive Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address Foreign Address State\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n...\r\nTcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN\u00a0\u00a0\r\n...\r\n<\/pre>\n
externo1 $ vncviewer localhost::7900 \r\n<\/pre>\n
externo1 $ ssh -L 0.0.0.0:7900:localhost:5900 user@interno1 \r\n<\/pre>\n
externo1 $ netstat -ltn\r\nActive Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address Foreign Address State\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n...\r\nTcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN\r\n... \r\n<\/pre>\n
externo2 $ vncviewer externo1::7900 \r\n<\/pre>\n
externo1 $ ssh -g -L 7900:localhost:5900 user@interno1 \r\n<\/pre>\n
externo1 $ ssh -L 0.0.0.0:7900:localhost:5900 user@interno1 \r\n<\/pre>\n
externo1 $ ssh -L 192.168.24.80:7900:localhost:5900 user@interno1\r\n\r\nexterno1 $ netstat -ltn\r\nActive Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address Foreign Address State \r\n... \r\nTcp 0 0 192.168.24.80:7900 0.0.0.0:* LISTEN\r\n...\r\n<\/pre>\n
externo1 $ ssh -R 7900:localhost:5900 user@interno1 \r\n<\/pre>\n
interno1 $ netstat -lnt\r\nActive Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address Foreign Address State \r\n... \r\nTcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN\r\n...\r\n<\/pre>\n
interno1 $ vncviewer localhost::7900 \r\n<\/pre>\n
externo1 $ ssh -R 0.0.0.0:7900:localhost:5900 user@interno1 \r\n<\/pre>\n
GatewayPorts clientspecified \r\n<\/pre>\n
sudo \/etc\/init.d\/ssh reload \r\n<\/pre>\n
interno1 $ netstat -ltn\r\nActive Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address Foreign Address State \r\n... \r\nTcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN\r\n...\r\n<\/pre>\n
interno2 $ internal vncviewer1::7900\r\n<\/pre>\n
externo1 $ ssh -L 7900:interno2:5900 user@interno1\r\n<\/pre>\n
externo1 $ vncviewer localhost::7900\r\n<\/pre>\n
externo1 $ ssh -R 7900:externo2:5900 user@interno1 \r\n<\/pre>\n
interno1 $ vncviewer localhost::7900 \r\n<\/pre>\n
externo1 $ ssh -L 0.0.0.0:7900:interno2:5900 user@interno1 \r\n<\/pre>\n
externo1 $ ssh -g -L 7900:interno2:5900 user@interno1 \r\n<\/pre>\n
externo2 $ vncviewer externo1::7900 \r\n<\/pre>\n
externo1 $ ssh -R 0.0.0.0:7900:externo2:5900 user@interno1 \r\n<\/pre>\n
GatewayPorts clientspecified \r\n<\/pre>\n
interno2 $ internal vncviewer1::7900 \r\n<\/pre>\n
# SOCKS server\r\nDynamicForward 1080\r\n\r\n# SSH redirects\r\nLocalForward 2221 serverlinux1: 22\r\nLocalForward 2222 serverlinux2: 22\r\nLocalForward 2223 172.16.23.45:22\r\nLocalForward 2224 172.16.23.48:22\r\n\r\n# RDP redirects for Windows systems\r\nLocalForward 3391 serverwindows1: 3389\r\nLocalForward 3392 serverwindows2: 3389\r\n\r\n# VNC redirects for systems with \"vncserver\"\r\nLocalForward 5902 serverlinux1: 5901\r\nLocalForward 5903 172.16.23.45:5901\r\n<\/pre>\n
externo1 $ ssh -F $HOME\/redirects user@interno1 \r\n<\/pre>\n
\n\n