{"id":38866,"date":"2025-05-21T12:36:43","date_gmt":"2025-05-21T04:36:43","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/38866.html"},"modified":"2025-05-21T12:36:43","modified_gmt":"2025-05-21T04:36:43","slug":"%e3%80%90%e5%be%ae%e7%9f%a5%e3%80%91%e8%87%aa%e5%b7%b1%e6%9c%89%e4%b8%80%e4%b8%aa%e4%ba%91%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%86%85%e7%bd%91%e7%a9%bf","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/38866.html","title":{"rendered":"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u80cc\u666f<\/li>\n<li>x \u8be6\u7ec6\u6b65\u9aa4<\/li>\n<li>\n<ul>\n<li>x.1 \u4e91\u670d\u52a1\u5668\u914d\u7f6e&#xff08;\u516c\u7f51&#xff09;<\/li>\n<li>x.2 \u5bb6\u5ead\u670d\u52a1\u5668\u914d\u7f6e&#xff08;\u5185\u7f51&#xff09;<\/li>\n<li>x.3 \u767b\u5f55\u8bbf\u95ee<\/li>\n<li>\n<ul>\n<li>x.3.1 \u76f4\u63a5\u767b\u5f55<\/li>\n<li>x.3.2 ssh config\u914d\u7f6e\u540e\u7b80\u5316\u767b\u5f55<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>y \u5176\u4ed6<\/li>\n<li>\n<ul>\n<li>y.1 \u5982\u4f55\u4f7f\u7528autossh\u4fdd\u6301\u81ea\u52a8\u91cd\u8fde&#xff1f;&#xff08;\u5bb6\u91cc\u670d\u52a1\u5668\u4e0a\u64cd\u4f5c&#xff09;<\/li>\n<li>\n<ul>\n<li>y.1.1 \u5b89\u88c5autossh<\/li>\n<li>y.1.2 \u6d4b\u8bd5\u53ef\u7528\u6027<\/li>\n<\/ul>\n<\/li>\n<li>y.2 \u5982\u4f55\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\u7cfb\u7edf\u670d\u52a1\u652f\u6301\u81ea\u52a8\u91cd\u542f<\/li>\n<li>y.2 \u5982\u679cautossh\u76f4\u63a5\u5b89\u88c5yum\u6e90\u6ca1\u6709\u5982\u4f55\u5904\u7406&#xff1f;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u80cc\u666f<\/h2>\n<p>\u5185\u7f51\u7a7f\u900f\u5728\u6dd8\u5b9d\u4e0a\u552e\u5356\u7684\u6bd4\u8f83\u591a&#xff0c;\u4ee5\u53ca\u5e38\u89c1\u7684\u82b1\u751f\u58f3\u6709\u76f8\u5173\u670d\u52a1\u3002\u539f\u7406\u6280\u672f\u4e94\u82b1\u516b\u95e8\u3002\u672c\u6587\u8bb0\u5f55\u4f7f\u7528 SSH \u53cd\u5411\u4ee3\u7406\u5b9e\u73b0\u5185\u7f51\u7a7f\u900f\u7684\u65b9\u5f0f\u3002\u524d\u63d0\u662f\u6709\u4e00\u4e2a\u62e5\u6709\u516c\u7f51\u56fa\u5b9aIP\u7684\u4e91\u670d\u52a1\u5668\u3002<\/p>\n<h2>x \u8be6\u7ec6\u6b65\u9aa4<\/h2>\n<h3>x.1 \u4e91\u670d\u52a1\u5668\u914d\u7f6e&#xff08;\u516c\u7f51&#xff09;<\/h3>\n<p>\u521b\u5efa\u4e2d\u8f6c\u7528\u6237&#xff08;\u53ef\u9009\u4f46\u66f4\u5b89\u5168&#xff09;<\/p>\n<p># \u5728\u4e91\u670d\u52a1\u5668\u4e0a\u6267\u884c<br \/>\nadduser reverse_proxy  # \u521b\u5efa\u7528\u6237<br \/>\npasswd reverse_proxy   # \u8bbe\u7f6e\u5bc6\u7801<br \/>\nusermod <span class=\"token operator\">&#8211;<\/span>aG sudo reverse_proxy  # \u6dfb\u52a0sudo\u6743\u9650&#xff08;\u53ef\u9009&#xff09;<\/p>\n<p>\u4fee\u6539 SSH \u914d\u7f6e<\/p>\n<p># \u7f16\u8f91\u4e91\u670d\u52a1\u5668\u7684SSH\u914d\u7f6e<br \/>\nvim <span class=\"token operator\">\/<\/span>etc<span class=\"token operator\">\/<\/span>ssh<span class=\"token operator\">\/<\/span>sshd_config<\/p>\n<p>\u6dfb\u52a0 \/ \u4fee\u6539\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p>GatewayPorts yes  # \u5141\u8bb8\u8fdc\u7a0b\u7aef\u53e3\u8f6c\u53d1\u88ab\u5916\u90e8\u8bbf\u95ee<br \/>\nPermitRootLogin yes  # \u5141\u8bb8root\u767b\u5f55&#xff08;\u82e5\u9700\u4f7f\u7528root&#xff09;<br \/>\nPasswordAuthentication yes  # \u542f\u7528\u5bc6\u7801\u8ba4\u8bc1&#xff08;\u6309\u9700&#xff09;<\/p>\n<p>\u91cd\u542f SSH \u670d\u52a1&#xff1a;<\/p>\n<p>systemctl restart sshd  # Ubuntu<span class=\"token operator\">\/<\/span>Debian<br \/>\n# \u6216<br \/>\nservice sshd restart  # CentOS<span class=\"token operator\">\/<\/span>RHEL<\/p>\n<h3>x.2 \u5bb6\u5ead\u670d\u52a1\u5668\u914d\u7f6e&#xff08;\u5185\u7f51&#xff09;<\/h3>\n<p><span class=\"token comment\"># \u5728\u5bb6\u5ead\u670d\u52a1\u5668\u4e0a\u6267\u884c&#xff08;\u66ff\u6362IP\u548c\u7aef\u53e3&#xff09;<\/span><br \/>\n<span class=\"token function\">ssh<\/span> -NfR <span class=\"token number\">5505<\/span>:localhost:22 reverse_proxy&#064;1.2.3.4 -p <span class=\"token number\">22<\/span><br \/>\n<span class=\"token comment\"># \u53c2\u6570\u8bf4\u660e&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># -N&#xff1a;\u4e0d\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4&#xff08;\u53ea\u8f6c\u53d1\u7aef\u53e3&#xff09;<\/span><br \/>\n<span class=\"token comment\"># -f&#xff1a;\u540e\u53f0\u8fd0\u884c<\/span><br \/>\n<span class=\"token comment\"># -R&#xff1a;\u8fdc\u7a0b\u8f6c\u53d1 [\u4e91\u670d\u52a1\u5668\u7aef\u53e3]:[\u5bb6\u5ead\u670d\u52a1\u5668IP]:[\u5bb6\u5ead\u670d\u52a1\u5668\u7aef\u53e3]<\/span><br \/>\n<span class=\"token comment\"># 1.2.3.4\u5047\u8bbe\u662f\u4e91\u670d\u52a1\u5668\u56fa\u5b9aIP<\/span><br \/>\n<span class=\"token comment\"># \u8fd9\u4e2a\u547d\u4ee4\u901a\u8fc7 SSH \u5efa\u7acb\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u96a7\u9053&#xff0c;\u5c06\u5185\u7f51\u670d\u52a1\u5668\u7684\u670d\u52a1\u66b4\u9732\u5230\u516c\u7f51\u3002<\/span><br \/>\n<span class=\"token comment\"># \u5c06\u4e91\u670d\u52a1\u5668\u7684 5505 \u7aef\u53e3\u6d41\u91cf\u8f6c\u53d1\u5230\u5185\u7f51\u670d\u52a1\u5668\u7684 22 \u7aef\u53e3<\/span><br \/>\n<span class=\"token comment\"># \u6700\u540e\u4e00\u4e2a-p 22\u662fssh\u53cd\u5411\u4ee3\u7406\u4e3a\u4e86\u8bbf\u95ee\u5f53\u524d\u4e91\u670d\u52a1\u5668\u7684\u7aef\u53e3&#xff0c;\u4e0e\u672c\u5b9e\u9a8c\u7aef\u53e3\u8f6c\u53d1\u65e0\u5173<\/span><br \/>\n<span class=\"token comment\"># \u7b2c\u4e00\u4e2alocalhost\u540e\u9762\u768422&#xff0c;\u662f\u5bb6\u91cc\u670d\u52a1\u5668\u7684ssh\u7aef\u53e3\u3002<\/span><\/p>\n<p>&#xff08;\u4e91\u670d\u52a1\u5668\u4e0a\u6267\u884c&#xff09;<br \/>\n\u7136\u540e\u4e91\u7aef\u67e5\u770b\u662f\u5426\u5f00\u542f\u4e865505\u7684\u76d1\u542c\u7aef\u53e3&#xff1a;<br \/>\n<span class=\"token function\">netstat<\/span> -tulpn <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> :5505<\/p>\n<p>\u5bb6\u91cc\u670d\u52a1\u5668\u6267\u884c&#xff1a;&#xff08;\u5982\u679c\u662f\u540e\u53f0\u670d\u52a1\u5668&#xff0c;\u53ef\u4ee5\u6307\u5b9a-f&#xff09; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043635-682d5853ec037.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u4e91\u670d\u52a1\u5668\u6267\u884c\u67e5\u770b\u7aef\u53e3\u662f\u5426\u5df2\u7ecf\u6253\u5f00 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043636-682d58543f920.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>x.3 \u767b\u5f55\u8bbf\u95ee<\/h3>\n<p>\u53ef\u4ee5\u4f7f\u7528ssh config\u914d\u7f6e&#xff0c;\u4e5f\u53ef\u4ee5\u5176\u4ed6<\/p>\n<h4>x.3.1 \u76f4\u63a5\u767b\u5f55<\/h4>\n<p>ssh <span class=\"token operator\">&#8211;<\/span>J reverse_proxy&#064;<span class=\"token number\">1.2<\/span><span class=\"token punctuation\">.<\/span><span class=\"token number\">3.4<\/span><span class=\"token operator\">:<\/span><span class=\"token number\">22<\/span> beiming&#064;localhost <span class=\"token operator\">&#8211;<\/span>p <span class=\"token number\">5505<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043636-682d585473ad9.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>x.3.2 ssh config\u914d\u7f6e\u540e\u7b80\u5316\u767b\u5f55<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043636-682d5854b2b14.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u5177\u4f53\u914d\u7f6e\u65b9\u6cd5\u53c2\u8003\u5144\u5f1f\u7bc7\u5173\u4e8e\u8df3\u677f\u673a\u7684\u6587\u7ae0 ssh config\u5982\u4f55\u914d\u7f6e\u7528host\u540d\u66ff\u4ee3root&#064;1.1.1.1&#xff0c;\u4ee5\u53ca\u5982\u4f55\u914d\u7f6e\u901a\u8fc7\u8df3\u677f\u673a\u767b\u5f55&#xff1f;<\/p>\n<p># \u4e91\u670d\u52a1\u5668\u914d\u7f6e<br \/>\nHost cloud<span class=\"token operator\">&#8211;<\/span>server<br \/>\n    HostName <span class=\"token number\">1.2<\/span><span class=\"token punctuation\">.<\/span><span class=\"token number\">3.4<\/span><br \/>\n    Port <span class=\"token number\">22<\/span><br \/>\n    User reverse_proxy<\/p>\n<p># \u5185\u7f51\u670d\u52a1\u5668\u914d\u7f6e<br \/>\nHost c168<br \/>\n    HostName localhost<br \/>\n    Port <span class=\"token number\">5505<\/span><br \/>\n    User beiming<br \/>\n    ProxyJump cloud<span class=\"token operator\">&#8211;<\/span>server<br \/>\n    IdentityFile <span class=\"token operator\">~<\/span><span class=\"token operator\">\/<\/span><span class=\"token punctuation\">.<\/span>ssh<span class=\"token operator\">\/<\/span>id_rsa<span class=\"token punctuation\">.<\/span>pub<\/p>\n<p>\u7136\u540e\u76f4\u63a5ssh c168\u6307\u5b9a\u670d\u52a1\u5668\u767b\u5f55 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043636-682d5854d7b89.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>y \u5176\u4ed6<\/h2>\n<h3>y.1 \u5982\u4f55\u4f7f\u7528autossh\u4fdd\u6301\u81ea\u52a8\u91cd\u8fde&#xff1f;&#xff08;\u5bb6\u91cc\u670d\u52a1\u5668\u4e0a\u64cd\u4f5c&#xff09;<\/h3>\n<h4>y.1.1 \u5b89\u88c5autossh<\/h4>\n<p>autossh\u901a\u5e38\u5305\u542b\u5728 EPEL&#xff08;Extra Packages for Enterprise Linux&#xff09;\u6e90\u4e2d\u3002\u5982\u679c\u5c1a\u672a\u542f\u7528 EPEL&#xff0c;\u9700\u5148\u5b89\u88c5&#xff1a;<\/p>\n<p># \u5b89\u88c5EPEL\u4ed3\u5e93&#xff08;\u9002\u7528\u4e8eCentOS <span class=\"token number\">7<\/span><span class=\"token operator\">\/<\/span><span class=\"token number\">8<\/span>&#xff09;<br \/>\nsudo yum install <span class=\"token operator\">&#8211;<\/span>y epel<span class=\"token operator\">&#8211;<\/span>release<\/p>\n<p># \u5b89\u88c5autossh<br \/>\nsudo yum install <span class=\"token operator\">&#8211;<\/span>y autossh<\/p>\n<p>\u7b14\u8005\u9047\u5230\u4e86\u6bd4\u8f83\u6162&#xff0c;\u624b\u52a8\u5b89\u88c5\u7684autossh<\/p>\n<p># \u5b89\u88c5\u7f16\u8bd1\u4f9d\u8d56<br \/>\nsudo yum install <span class=\"token operator\">&#8211;<\/span>y gcc make openssh<span class=\"token operator\">&#8211;<\/span>devel<\/p>\n<p># \u4e0b\u8f7d\u5e76\u89e3\u538bautossh\u6e90\u7801<br \/>\nwget https<span class=\"token operator\">:<\/span><span class=\"token comment\">\/\/www.harding.motd.ca\/autossh\/autossh-1.4g.tgz<\/span><br \/>\ntar <span class=\"token operator\">&#8211;<\/span>xzvf autossh<span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1.4<\/span>g<span class=\"token punctuation\">.<\/span>tgz<br \/>\ncd autossh<span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1.4<\/span>g<\/p>\n<p># \u7f16\u8bd1\u5e76\u5b89\u88c5<br \/>\n<span class=\"token punctuation\">.<\/span><span class=\"token operator\">\/<\/span>configure<br \/>\nmake<br \/>\nsudo make install<\/p>\n<ul>\n<li>\u4e0b\u8f7d <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043637-682d585510288.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/li>\n<li>\u89e3\u538b <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043637-682d585591456.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/li>\n<li>\u7f16\u8bd1\u5b89\u88c5 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043637-682d5855dd811.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043638-682d5856678b3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/li>\n<\/ul>\n<h4>y.1.2 \u6d4b\u8bd5\u53ef\u7528\u6027<\/h4>\n<p><span class=\"token comment\"># \u521b\u5efa\u6301\u4e45\u8fde\u63a5&#xff08;\u66ff\u6362IP\u548c\u7aef\u53e3&#xff09;<\/span><br \/>\nautossh -M <span class=\"token number\">0<\/span> -fNR <span class=\"token number\">8080<\/span>:localhost:80 reverse_proxy&#064;1.2.3.4 -p <span class=\"token number\">22<\/span><br \/>\n<span class=\"token comment\"># -M 0&#xff1a;\u4e0d\u4f7f\u7528\u76d1\u63a7\u7aef\u53e3<\/span><br \/>\n<span class=\"token comment\"># -f \u540e\u53f0\u8fd0\u884c<\/span><\/p>\n<h3>y.2 \u5982\u4f55\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\u7cfb\u7edf\u670d\u52a1\u652f\u6301\u81ea\u52a8\u91cd\u542f<\/h3>\n<p># \u521b\u5efa\u670d\u52a1\u6587\u4ef6&#xff08;\u5bb6\u5ead\u670d\u52a1\u5668&#xff09;<br \/>\nvim <span class=\"token operator\">\/<\/span>etc<span class=\"token operator\">\/<\/span>systemd<span class=\"token operator\">\/<\/span>system<span class=\"token operator\">\/<\/span>autossh<span class=\"token punctuation\">.<\/span>service<\/p>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>Unit<span class=\"token punctuation\">]<\/span><br \/>\nDescription<span class=\"token operator\">&#061;<\/span>AutoSSH Tunnel<br \/>\nAfter<span class=\"token operator\">&#061;<\/span>network<span class=\"token punctuation\">.<\/span>target<\/p>\n<p><span class=\"token punctuation\">[<\/span>Service<span class=\"token punctuation\">]<\/span><br \/>\nUser<span class=\"token operator\">&#061;<\/span>root  # \u6216\u5176\u4ed6\u7528\u6237<br \/>\nEnvironment<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;AUTOSSH_GATETIME&#061;0&#034;<\/span><br \/>\nExecStart<span class=\"token operator\">&#061;<\/span><span class=\"token operator\">\/<\/span>usr<span class=\"token operator\">\/<\/span>bin<span class=\"token operator\">\/<\/span>autossh <span class=\"token operator\">&#8211;<\/span>M <span class=\"token number\">0<\/span> <span class=\"token operator\">&#8211;<\/span>fNR <span class=\"token number\">5505<\/span><span class=\"token operator\">:<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">22<\/span> reverse_proxy&#064;<span class=\"token number\">1.2<\/span><span class=\"token punctuation\">.<\/span><span class=\"token number\">3.4<\/span> <span class=\"token operator\">&#8211;<\/span>p <span class=\"token number\">22<\/span><br \/>\nRestart<span class=\"token operator\">&#061;<\/span>always<br \/>\nRestartSec<span class=\"token operator\">&#061;<\/span><span class=\"token number\">5<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>Install<span class=\"token punctuation\">]<\/span><br \/>\nWantedBy<span class=\"token operator\">&#061;<\/span>multi<span class=\"token operator\">&#8211;<\/span>user<span class=\"token punctuation\">.<\/span>target<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043638-682d5856ea72e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u542f\u7528\u5e76\u542f\u52a8\u670d\u52a1&#xff1a;<\/p>\n<p>systemctl enable autossh<br \/>\nsystemctl start autossh<br \/>\nsystemctl status autossh  # \u68c0\u67e5\u72b6\u6001<\/p>\n<p>(\u4e0d\u8fc7\u8fd9\u91cc\u8fd8\u6709\u70b9\u95ee\u9898 \u542f\u52a8\u8001\u662f\u5931\u8d25&#xff0c;\u4ee5\u540e\u518d\u66f4\u65b0)<\/p>\n<p>\u53e6\u5916\u4e3a\u4e86\u65b9\u4fbf\u81ea\u52a8\u91cd\u542f\u514d\u5bc6\u8f93\u5165\u9700\u8981\u8bbe\u7f6e\u4e0b\u767b\u5f55\u514d\u5bc6ssh-copy-id reverse_proxy&#064;1.2.3.4&#xff0c;\u5c31\u662f\u672c\u673a\u514d\u5bc6\u767b\u5f55\u5230\u4e91\u670d\u52a1\u5668\u7684reverse_proxy\u8d26\u6237\u7684&#xff0c;\u5177\u4f53\u914d\u7f6e\u65b9\u5f0f\u53c2\u8003\u5144\u5f1f\u7bc7&#xff1a;\u3010\u5fae\u77e5\u3011ssh\u5982\u4f55\u6307\u5b9a\u514d\u5bc6\u76842\u79cd\u7b80\u5355\u65b9\u5f0f<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043639-682d58575b1d2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u7136\u540e\u8bd5\u4e00\u4e0bautossh\u6216\u8005ssh\u53cd\u5411\u4ee3\u7406\u662f\u5426\u8fd8\u9700\u8981\u8f93\u5165\u5bc6\u7801:<\/p>\n<h3>y.2 \u5982\u679cautossh\u76f4\u63a5\u5b89\u88c5yum\u6e90\u6ca1\u6709\u5982\u4f55\u5904\u7406&#xff1f;<\/h3>\n<p><span class=\"token punctuation\">[<\/span>root&#064;localhost ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum install autossh  # CentOS\/RHEL<\/span><br \/>\nLast metadata expiration check: <span class=\"token number\">1<\/span>:52:41 ago on Sun <span class=\"token number\">18<\/span> May <span class=\"token number\">2025<\/span> 03:18:51 PM CST.<br \/>\nNo match <span class=\"token keyword\">for<\/span> argument: autossh<br \/>\nError: Unable to <span class=\"token function\">find<\/span> a match: autossh<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043640-682d58582df55.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u9700\u8981\u5b89\u88c5epel-release sudo yum install -y epel-release&#xff0c;autossh\u901a\u5e38\u5305\u542b\u5728 EPEL&#xff08;Extra Packages for Enterprise Linux&#xff09;\u6e90\u4e2d\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043640-682d58585d0db.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u7136\u540e\u5b89\u88c5autossh&#xff1a;sudo yum install -y autossh <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043641-682d58598c1be.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb887\u6b21\uff0c\u70b9\u8d5e8\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u5185\u7f51\u7a7f\u900f\u5728\u6dd8\u5b9d\u4e0a\u552e\u5356\u7684\u6bd4\u8f83\u591a\uff0c\u4ee5\u53ca\u5e38\u89c1\u7684\u82b1\u751f\u58f3\u6709\u76f8\u5173\u670d\u52a1\u3002\u672c\u6587\u8bb0\u5f55\u4f7f\u7528 SSH \u53cd\u5411\u4ee3\u7406\u5b9e\u73b0\u5185\u7f51\u7a7f\u900f\u7684\u65b9\u5f0f\u3002autossh\u901a\u5e38\u5305\u542b\u5728 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u6e90\u4e2d\u3002\uff0cautossh\u901a\u5e38\u5305\u542b\u5728 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u6e90\u4e2d\u3002\u5bb6\u91cc\u670d\u52a1\u5668\u6267\u884c\uff1a\uff08\u5982\u679c\u662f\u540e\u53f0\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u6307\u5b9a-f\uff09\u53ef\u4ee5\u4f7f\u7528ssh config\u914d\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u5176\u4ed6\u3002\u7b14\u8005\u9047\u5230\u4e86\u6bd4\u8f83\u6162\uff0c\u624b\u52a8\u5b89\u88c5\u7684autossh\u3002\u521b\u5efa\u4e2d\u8f6c\u7528\u6237\uff08\u53ef\u9009\u4f46\u66f4\u5b89\u5168\uff09<\/p>\n","protected":false},"author":2,"featured_media":38852,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1817,77,43],"topic":[],"class_list":["post-38866","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-ssh","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/38866.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb887\u6b21\uff0c\u70b9\u8d5e8\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u5185\u7f51\u7a7f\u900f\u5728\u6dd8\u5b9d\u4e0a\u552e\u5356\u7684\u6bd4\u8f83\u591a\uff0c\u4ee5\u53ca\u5e38\u89c1\u7684\u82b1\u751f\u58f3\u6709\u76f8\u5173\u670d\u52a1\u3002\u672c\u6587\u8bb0\u5f55\u4f7f\u7528 SSH \u53cd\u5411\u4ee3\u7406\u5b9e\u73b0\u5185\u7f51\u7a7f\u900f\u7684\u65b9\u5f0f\u3002autossh\u901a\u5e38\u5305\u542b\u5728 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u6e90\u4e2d\u3002\uff0cautossh\u901a\u5e38\u5305\u542b\u5728 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u6e90\u4e2d\u3002\u5bb6\u91cc\u670d\u52a1\u5668\u6267\u884c\uff1a\uff08\u5982\u679c\u662f\u540e\u53f0\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u6307\u5b9a-f\uff09\u53ef\u4ee5\u4f7f\u7528ssh config\u914d\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u5176\u4ed6\u3002\u7b14\u8005\u9047\u5230\u4e86\u6bd4\u8f83\u6162\uff0c\u624b\u52a8\u5b89\u88c5\u7684autossh\u3002\u521b\u5efa\u4e2d\u8f6c\u7528\u6237\uff08\u53ef\u9009\u4f46\u66f4\u5b89\u5168\uff09\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/38866.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-21T04:36:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043635-682d5853ec037.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38866.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/38866.html\",\"name\":\"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-21T04:36:43+00:00\",\"dateModified\":\"2025-05-21T04:36:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/38866.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/38866.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38866.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/38866.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb887\u6b21\uff0c\u70b9\u8d5e8\u6b21\uff0c\u6536\u85cf24\u6b21\u3002\u5185\u7f51\u7a7f\u900f\u5728\u6dd8\u5b9d\u4e0a\u552e\u5356\u7684\u6bd4\u8f83\u591a\uff0c\u4ee5\u53ca\u5e38\u89c1\u7684\u82b1\u751f\u58f3\u6709\u76f8\u5173\u670d\u52a1\u3002\u672c\u6587\u8bb0\u5f55\u4f7f\u7528 SSH \u53cd\u5411\u4ee3\u7406\u5b9e\u73b0\u5185\u7f51\u7a7f\u900f\u7684\u65b9\u5f0f\u3002autossh\u901a\u5e38\u5305\u542b\u5728 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u6e90\u4e2d\u3002\uff0cautossh\u901a\u5e38\u5305\u542b\u5728 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u6e90\u4e2d\u3002\u5bb6\u91cc\u670d\u52a1\u5668\u6267\u884c\uff1a\uff08\u5982\u679c\u662f\u540e\u53f0\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u6307\u5b9a-f\uff09\u53ef\u4ee5\u4f7f\u7528ssh config\u914d\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u5176\u4ed6\u3002\u7b14\u8005\u9047\u5230\u4e86\u6bd4\u8f83\u6162\uff0c\u624b\u52a8\u5b89\u88c5\u7684autossh\u3002\u521b\u5efa\u4e2d\u8f6c\u7528\u6237\uff08\u53ef\u9009\u4f46\u66f4\u5b89\u5168\uff09","og_url":"https:\/\/www.wsisp.com\/helps\/38866.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-21T04:36:43+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521043635-682d5853ec037.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/38866.html","url":"https:\/\/www.wsisp.com\/helps\/38866.html","name":"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-21T04:36:43+00:00","dateModified":"2025-05-21T04:36:43+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/38866.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/38866.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/38866.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u5fae\u77e5\u3011\u81ea\u5df1\u6709\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5185\u7f51\u7a7f\u900f\u529f\u80fd\u8bbf\u95ee\u5bb6\u91cc\u7684\u670d\u52a1\u5668\uff1f\uff08ssh -NfR 5505:localhost:22 reverse_proxy@1.2.3.4 -p 22\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=38866"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38866\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/38852"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=38866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=38866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=38866"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=38866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}