{"id":84361,"date":"2026-07-26T12:01:56","date_gmt":"2026-07-26T04:01:56","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/84361.html"},"modified":"2026-07-26T12:01:56","modified_gmt":"2026-07-26T04:01:56","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%89%e5%85%a8%e5%8a%a0%e5%9b%ba%e5%9f%ba%e7%a1%80%e6%8e%aa%e6%96%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/84361.html","title":{"rendered":"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd"},"content":{"rendered":"<h4>\u524d\u8a00<\/h4>\n<p>\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u5b83\u4eec\u7684\u6838\u5fc3\u76ee\u7684\u90fd\u662f\u4e3a\u4e86\u589e\u52a0\u653b\u51fb\u8005\u7684\u6210\u672c&#xff0c;\u5e76\u51cf\u5c11\u88ab\u81ea\u52a8\u5316\u811a\u672c\u653b\u7834\u7684\u6982\u7387<\/p>\n<ul>\n<li>\n<p>\u7981\u7528 Root \u7528\u6237\u767b\u5f55<\/p>\n<ul>\n<li>\u589e\u52a0\u66b4\u529b\u7834\u89e3\u7684\u96be\u5ea6&#xff08;\u6700\u4e3b\u8981\u539f\u56e0&#xff09;<\/li>\n<li>\u6743\u9650\u5ba1\u8ba1\u4e0e\u8d23\u4efb\u8ffd\u6eaf&#xff08;\u533a\u5206\u56e2\u961f\u7528\u6237&#xff09;<\/li>\n<li>\u9632\u6b62\u8bef\u64cd\u4f5c&#xff08;\u6700\u5c0f\u6743\u9650\u539f\u5219&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4fee\u6539 SSH \u9ed8\u8ba4\u7aef\u53e3 (Port 22)<\/p>\n<ul>\n<li>\u89c4\u907f\u81ea\u52a8\u5316\u626b\u63cf\u811a\u672c&#xff08;\u4e3b\u8981\u4f5c\u7528&#xff09;<\/li>\n<li>\u4fdd\u6301\/var\/log\/secure\u65e5\u5fd7\u5e72\u51c0<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>\u7b2c\u4e00\u6b65&#xff1a;\u521b\u5efa\u4e00\u4e2a\u62e5\u6709sudo\u6743\u9650\u7684\u666e\u901a\u7528\u6237<\/h4>\n<p>\u5728\u7981\u7528Root\u767b\u5f55\u4e4b\u524d&#xff0c;\u4f60\u5fc5\u987b\u786e\u4fdd\u6709\u4e00\u4e2a\u666e\u901a\u7528\u6237\u53ef\u4ee5\u767b\u5f55\u5e76\u6267\u884c\u7ba1\u7406\u5458\u547d\u4ee4&#xff08;sudo&#xff09;\u3002<\/p>\n<li>\u521b\u5efa\u65b0\u7528\u6237 (\u5047\u8bbe\u7528\u6237\u540d\u4e3a adminuser)&#xff1a;<\/li>\n<p>useradd -m adminuser<\/p>\n<li>\u8bbe\u7f6e\u5bc6\u7801&#xff1a;<\/li>\n<p>passwd adminuser<br \/>\n# \u8f93\u5165\u4e24\u6b21\u65b0\u5bc6\u7801<\/p>\n<p>\u4f7f\u7528 SSH \u5bc6\u94a5\u5bf9\u767b\u5f55&#xff08;\u6700\u5f3a\u63a8\u8350&#xff09;<\/p>\n<p>\u76ee\u524d\u6700\u4e3b\u6d41\u7684SSH\u9a8c\u8bc1\u65b9\u5f0f\u3002\u5728\u4f60\u7684\u7535\u8111\u751f\u6210\u4e00\u5bf9\u5bc6\u94a5&#xff08;\u516c\u94a5\u548c\u79c1\u94a5&#xff09;&#xff0c;\u628a\u516c\u94a5\u653e\u5230\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n<ul>\n<li>\u914d\u7f6e&#xff1a; \u5728 \/etc\/ssh\/sshd_config \u4e2d\u8bbe\u7f6e&#xff1a;<\/li>\n<\/ul>\n<p>PubkeyAuthentication yes    # \u5f00\u542f\u5bc6\u94a5\u767b\u5f55<br \/>\nPasswordAuthentication no   # \u5f7b\u5e95\u5173\u95ed\u5bc6\u7801\u767b\u5f55&#xff08;!&#xff09;<\/p>\n<ul>\n<li>\u6ce8\u610f&#xff1a;\u5728\u5173\u95ed\u5bc6\u7801\u767b\u5f55\u524d&#xff0c;\u52a1\u5fc5\u786e\u8ba4\u5bc6\u94a5\u767b\u5f55\u5df2\u7ecf\u914d\u7f6e\u6210\u529f\u3002<\/li>\n<\/ul>\n<li>\n<p>\u6388\u4e88 sudo \u6743\u9650&#xff1a;<\/p>\n<li>CentOS \/ RHEL \/ Fedora:<\/li>\n<li>\nusermod -aG wheel adminuser<\/p>\n<\/li>\n<li>Ubuntu \/ Debian:<\/li>\n<li>\nusermod -aG sudo adminuser<\/p>\n<\/li>\n<\/li>\n<li>\n<p>\u5173\u95ed sudo \u5bc6\u7801&#xff1a; &#xff08;\u53ef\u9009-\u53d6\u6d88 sudo \u5bc6\u7801\u867d\u7136\u65b9\u4fbf&#xff0c;\u4f46\u964d\u4f4e\u4e86\u5b89\u5168\u6027&#xff09;<\/p>\n<\/li>\n<p>visudo<\/p>\n<ul>\n<li>\u8fd9\u4f1a\u6253\u5f00 \/etc\/sudoers \u6587\u4ef6\u3002<\/li>\n<li>\u9ed8\u8ba4\u7f16\u8f91\u5668\u53ef\u80fd\u662f nano&#xff08;\u4e0b\u65b9\u6709\u5feb\u6377\u952e\u63d0\u793a&#xff09;\u6216 vi\/vim<\/li>\n<\/ul>\n<p>\u4f60\u9700\u8981\u627e\u5230\u5408\u9002\u7684\u4f4d\u7f6e&#xff08;\u901a\u5e38\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u5373\u53ef&#xff09;&#xff0c;\u6839\u636e\u4f60\u7684\u9700\u6c42\u9009\u62e9\u4ee5\u4e0b \u4e00\u79cd \u65b9\u5f0f&#xff1a;<\/p>\n<h5>\u65b9\u5f0f A&#xff1a;\u53ea\u9488\u5bf9\u7279\u5b9a\u7528\u6237&#xff08;\u63a8\u8350&#xff09;<\/h5>\n<p>\u5047\u8bbe\u4f60\u7684\u7528\u6237\u540d\u662f adminuser&#xff0c;\u5728\u6587\u4ef6\u6700\u540e\u4e00\u884c\u6dfb\u52a0&#xff1a;<\/p>\n<p>adminuser ALL&#061;(ALL:ALL) NOPASSWD: ALL<\/p>\n<ul>\n<li>\u8bf7\u5c06 adminuser \u66ff\u6362\u4e3a\u4f60\u5b9e\u9645\u7684\u7528\u6237\u540d\u3002<\/li>\n<li>NOPASSWD: \u662f\u5173\u952e\u6307\u4ee4&#xff08;\u6ce8\u610f\u5192\u53f7\u548c\u7a7a\u683c&#xff09;\u3002<\/li>\n<\/ul>\n<h5>\u65b9\u5f0f B&#xff1a;\u9488\u5bf9\u6574\u4e2a\u7528\u6237\u7ec4&#xff08;\u4f8b\u5982 wheel \u6216 sudo \u7ec4&#xff09;<\/h5>\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u6240\u6709\u62e5\u6709\u7ba1\u7406\u5458\u6743\u9650\u7684\u7528\u6237\u90fd\u4e0d\u9700\u8981\u5bc6\u7801&#xff1a;<\/p>\n<p>\u627e\u5230\u7c7b\u4f3c\u4e0b\u9762\u8fd9\u4e00\u884c&#xff08;\u4ee5 % \u5f00\u5934\u8868\u793a\u7ec4&#xff09;&#xff1a;<\/p>\n<ul>\n<li>CentOS \/ RHEL (\u901a\u5e38\u662f %wheel):<\/li>\n<\/ul>\n<p>## \u627e\u5230\u8fd9\u4e00\u884c<br \/>\n%wheel  ALL&#061;(ALL)       ALL<\/p>\n<p>## \u4fee\u6539\u4e3a:<br \/>\n%wheel  ALL&#061;(ALL)       NOPASSWD: ALL<\/p>\n<ul>\n<li>Ubuntu\/ Debian (\u901a\u5e38\u662f %sudo):<\/li>\n<\/ul>\n<p>## \u627e\u5230\u8fd9\u4e00\u884c<br \/>\n%sudo   ALL&#061;(ALL:ALL) ALL<\/p>\n<p>## \u4fee\u6539\u4e3a:<br \/>\n%sudo   ALL&#061;(ALL:ALL) NOPASSWD: ALL<\/p>\n<h5>\u4fdd\u5b58\u5e76\u9000\u51fa<\/h5>\n<ul>\n<li>\n<p>\u5982\u679c\u4f60\u662f\u5728 nano \u7f16\u8f91\u5668\u4e2d (\u5c4f\u5e55\u4e0b\u65b9\u6709 ^O Write Out \u7b49\u63d0\u793a):<\/p>\n<ul>\n<li>\u6309 Ctrl &#043; O&#xff0c;\u7136\u540e\u6309 Enter&#xff08;\u56de\u8f66&#xff09;\u4fdd\u5b58\u3002<\/li>\n<li>\u6309 Ctrl &#043; X \u9000\u51fa\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5982\u679c\u4f60\u662f\u5728 vi \u6216 vim \u7f16\u8f91\u5668\u4e2d:<\/p>\n<ul>\n<li>\u6309 Esc \u952e\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\u3002<\/li>\n<li>\u8f93\u5165 :wq \u5e76\u6309\u56de\u8f66&#xff08;\u4fdd\u5b58\u5e76\u9000\u51fa&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>\u9a8c\u8bc1<\/h5>\n<p>\u65e0\u9700\u91cd\u542f\u670d\u52a1&#xff0c;\u7acb\u5373\u751f\u6548\u3002\u53ef\u4ee5\u8f93\u5165\u4e00\u4e2a sudo \u547d\u4ee4\u6d4b\u8bd5&#xff1a;<\/p>\n<p>sudo ls \/root<\/p>\n<p>\u5982\u679c\u76f4\u63a5\u5217\u51fa\u4e86\u6587\u4ef6\u800c\u6ca1\u6709\u63d0\u793a\u8f93\u5165\u5bc6\u7801&#xff0c;\u8bf4\u660e\u914d\u7f6e\u6210\u529f\u3002<\/p>\n<hr \/>\n<h4>\u7b2c\u4e8c\u6b65&#xff1a;\u4fee\u6539\u7528\u6237\u5bc6\u7801<\/h4>\n<p>\u5982\u679c\u4f60\u9700\u8981\u4fee\u6539\u5f53\u524d\u7528\u6237&#xff08;\u5305\u62ecroot&#xff09;\u6216\u5176\u4ed6\u7528\u6237\u7684\u5bc6\u7801\u3002<\/p>\n<ul>\n<li>\u4fee\u6539\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u5bc6\u7801&#xff1a;<\/li>\n<\/ul>\n<p>passwd<\/p>\n<ul>\n<li>\u4fee\u6539\u7279\u5b9a\u7528\u6237\u7684\u5bc6\u7801 (\u9700\u8981root\u6743\u9650) &#xff1a;<\/li>\n<\/ul>\n<p>passwd \u7528\u6237\u540d<br \/>\n# \u4f8b\u5982: passwd root \u6216 passwd adminuser<\/p>\n<hr \/>\n<h4>\u7b2c\u4e09\u6b65&#xff1a;\u4fee\u6539SSH\u914d\u7f6e\u6587\u4ef6 (\u7aef\u53e3\u4e0eRoot\u767b\u5f55)<\/h4>\n<p>SSH\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e \/etc\/ssh\/sshd_config\u3002<\/p>\n<li>\u5907\u4efd\u914d\u7f6e\u6587\u4ef6 (\u517b\u6210\u597d\u4e60\u60ef)&#xff1a;<\/li>\n<p>cp \/etc\/ssh\/sshd_config \/etc\/ssh\/sshd_config.bak<\/p>\n<li>\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6&#xff1a; \u4f7f\u7528\u4f60\u719f\u6089\u7684\u7f16\u8f91\u5668&#xff08;\u5982 vi, vim, \u6216 nano&#xff09;&#xff1a;<\/li>\n<p>vim \/etc\/ssh\/sshd_config<\/p>\n<li>\n<p>\u4fee\u6539 SSH ****\u7aef\u53e3&#xff1a; \u627e\u5230 #Port 22 \u8fd9\u4e00\u884c\u3002<\/p>\n<li>\u53bb\u6389\u524d\u9762\u7684 # \u6ce8\u91ca\u7b26\u53f7\u3002<\/li>\n<li>\u5c06 22 \u4fee\u6539\u4e3a\u4f60\u60f3\u8981\u7684\u7aef\u53e3\u53f7&#xff08;\u5efa\u8bae\u5728 1024-65535 \u4e4b\u95f4&#xff0c;\u907f\u514d\u51b2\u7a81&#xff0c;\u4f8b\u5982 2222&#xff09;\u3002<\/li>\n<li>\u4fee\u6539\u524d: #Port 22<\/li>\n<li>\u4fee\u6539\u540e: Port 2222<\/li>\n<\/li>\n<li>\n<p>\u7981\u7528 Root \u767b\u5f55&#xff1a; \u627e\u5230 PermitRootLogin \u8fd9\u4e00\u884c\u3002<\/p>\n<li>\u5982\u679c\u5b83\u662f yes&#xff0c;\u6539\u4e3a no\u3002<\/li>\n<li>\u4fee\u6539\u540e: PermitRootLogin no<\/li>\n<\/li>\n<li>\n<p>\u4fdd\u5b58\u5e76\u9000\u51fa&#xff1a;<\/p>\n<li>\u5982\u679c\u662f vim: \u6309 Esc&#xff0c;\u8f93\u5165 :wq&#xff0c;\u56de\u8f66\u3002<\/li>\n<li>\u5982\u679c\u662f nano: \u6309 Ctrl&#043;O \u4fdd\u5b58&#xff0c;Ctrl&#043;X \u9000\u51fa\u3002<\/li>\n<\/li>\n<h5>\u5f00\u542f SSH \u7a7a\u95f2\u8d85\u65f6\u81ea\u52a8\u767b\u51fa&#xff08;\u5e38\u642d\u914d\u4f7f\u7528-\u53ef\u9009&#xff09;<\/h5>\n<p>\u9632\u6b62\u4f60\u79bb\u5f00\u7535\u8111\u65f6&#xff0c;\u5df2\u7ecf\u8fde\u63a5\u7684SSH\u7a97\u53e3\u88ab\u4ed6\u4eba\u6076\u610f\u64cd\u4f5c\u3002<\/p>\n<ul>\n<li>\u505a\u6cd5&#xff1a;\u4fee\u6539 \/etc\/ssh\/sshd_config&#xff1a; (\u6216\u8005\u914d\u7f6e TMOUT \u73af\u5883\u53d8\u91cf )<\/li>\n<\/ul>\n<p>ClientAliveInterval 300   # \u670d\u52a1\u7aef\u6bcf300\u79d2\u5411\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u6b21\u5fc3\u8df3<br \/>\nClientAliveCountMax 0     # \u5982\u679c\u5ba2\u6237\u7aef\u6ca1\u54cd\u5e94&#xff08;\u6216\u7a7a\u95f2&#xff09;&#xff0c;\u5141\u8bb8\u5c1d\u8bd50\u6b21\u540e\u65ad\u5f00<\/p>\n<ul>\n<li>\u4f5c\u7528&#xff1a;\u5982\u679c\u4f60\u53bb\u4e0a\u5395\u6240\u6216\u4e0b\u73ed\u5fd8\u8bb0\u5173\u7ec8\u7aef&#xff0c;5\u5206\u949f\u65e0\u64cd\u4f5c\u540e&#xff0c;\u8fde\u63a5\u4f1a\u81ea\u52a8\u65ad\u5f00\u3002<\/li>\n<\/ul>\n<h5>\u5b89\u88c5\u9632\u66b4\u529b\u7834\u89e3\u795e\u5668&#xff1a;Fail2Ban&#xff08;\u53ef\u9009&#xff09;<\/h5>\n<p>Fail2Ban \u662f\u4e00\u4e2a\u81ea\u52a8\u5316\u4fdd\u62a4\u5de5\u5177&#xff0c;\u5b83\u4f1a\u76d1\u63a7\u7cfb\u7edf\u65e5\u5fd7\u3002<\/p>\n<ul>\n<li>\n<p>\u539f\u7406&#xff1a;\u5982\u679c\u68c0\u6d4b\u5230\u67d0\u4e2aIP\u5728\u77ed\u65f6\u95f4\u5185\u8fde\u7eed\u8f93\u9519\u5bc6\u7801 N \u6b21&#xff08;\u4f8b\u59825\u6b21&#xff09;&#xff0c;\u5b83\u4f1a\u7acb\u5373\u4fee\u6539\u9632\u706b\u5899\u89c4\u5219&#xff0c;\u5c06\u8fd9\u4e2aIP\u5c01\u7981&#xff08;Ban\u6389&#xff09;\u4e00\u6bb5\u65f6\u95f4&#xff08;\u4f8b\u59821\u5c0f\u65f6\u6216\u6c38\u4e45&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5&#xff1a;<\/p>\n<ul>\n<li>Ubuntu\/Debian: sudo apt install fail2ban<\/li>\n<li>CentOS: sudo yum install fail2ban<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f5c\u7528&#xff1a;\u5b83\u662f\u4fee\u6539SSH\u7aef\u53e3\u7684\u6700\u4f73\u642d\u6863\u3002\u5373\u4f7f\u4f60\u6ca1\u6539\u7aef\u53e3&#xff0c;\u6709\u4e86Fail2Ban&#xff0c;\u66b4\u529b\u7834\u89e3\u811a\u672c\u8bd5\u51e0\u6b21\u5c31\u88ab\u62c9\u9ed1\u4e86&#xff0c;\u65e0\u6cd5\u7ee7\u7eed\u5c1d\u8bd5<\/p>\n<\/li>\n<\/ul>\n<h5>\u542f\u7528\u53cc\u56e0\u5b50\u8ba4\u8bc1 (\u53ef\u9009)<\/h5>\n<p>\u7ed9SSH\u767b\u5f55\u52a0\u4e00\u628a\u201c\u52a8\u6001\u9501\u201d\u3002<\/p>\n<ul>\n<li>\u505a\u6cd5&#xff1a;\u5728\u670d\u52a1\u5668\u5b89\u88c5 google-authenticator \u6a21\u5757\u3002\u767b\u5f55\u65f6&#xff0c;\u9664\u4e86\u8f93\u5165\u5bc6\u7801&#xff08;\u6216\u5bc6\u94a5&#xff09;&#xff0c;\u8fd8\u9700\u8981\u8f93\u5165\u624b\u673a App&#xff08;\u5982 Google Authenticator \u6216 Microsoft Authenticator&#xff09;\u4e0a\u6bcf30\u79d2\u53d8\u5316\u7684 6 \u4f4d\u6570\u5b57\u9a8c\u8bc1\u7801\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u7b2c\u56db\u6b65&#xff1a;\u914d\u7f6e\u9632\u706b\u5899 (\u81f3\u5173\u91cd\u8981)<\/h4>\n<p>\u5728 \u91cd\u542f SSH \u670d\u52a1\u4e4b\u524d&#xff0c;\u5fc5\u987b\u653e\u884c\u65b0 \u7aef\u53e3 &#xff0c;\u5426\u5219\u4f60\u4f1a\u88ab\u9501\u5728\u5916\u9762&#xff01;<\/p>\n<p>\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5bf9\u5e94\u7684\u9632\u706b\u5899\u547d\u4ee4&#xff1a;<\/p>\n<h5>\u60c5\u51b5 A: \u5982\u679c\u4f60\u662f CentOS 7\/8\/9 \/ RHEL (\u4f7f\u7528 firewalld)<\/h5>\n<li>\u653e\u884c\u65b0 \u7aef\u53e3 (\u4f8b\u5982 2222)&#xff1a;<\/li>\n<p>firewall-cmd &#8211;permanent &#8211;add-port&#061;2222\/tcp<\/p>\n<li>\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899&#xff1a;<\/li>\n<p>firewall-cmd &#8211;reload<\/p>\n<li>SELinux \u8bbe\u7f6e (\u5982\u679c\u662f CentOS \/ RHEL \u4e14\u5f00\u542f\u4e86SELinux) &#xff1a; \u5982\u679c\u4fee\u6539\u4e86\u7aef\u53e3&#xff0c;SELinux\u53ef\u80fd\u4f1a\u963b\u6b62SSH\u5728\u975e\u6807\u51c6\u7aef\u53e3\u8fd0\u884c\u3002<\/li>\n<p># \u5b89\u88c5\u7ba1\u7406\u5de5\u5177 (\u5982\u679c\u6ca1\u6709)<br \/>\nyum install -y policycoreutils-python-utils  # CentOS 8\/Stream<br \/>\n# \u6216 yum install -y policycoreutils-python   # CentOS 7<\/p>\n<p># \u5141\u8bb8SSH\u4f7f\u7528\u65b0\u7aef\u53e3<br \/>\nsemanage port -a -t ssh_port_t -p tcp 2222<\/p>\n<h5>\u60c5\u51b5 B: \u5982\u679c\u4f60\u662f Ubuntu \/ Debian (\u4f7f\u7528 ufw)<\/h5>\n<li>\u653e\u884c\u65b0 \u7aef\u53e3&#xff1a;<\/li>\n<p>ufw allow 2222\/tcp<\/p>\n<li>(\u6ce8\u610f&#xff1a;\u5982\u679c\u4f60\u8fd8\u8981\u4fdd\u7559 22\u7aef\u53e3 \u4f5c\u4e3a\u5907\u7528&#xff0c;\u53ef\u4ee5\u6682\u65f6\u4e0d\u5220&#xff0c;\u786e\u8ba4\u65e0\u8bef\u540e\u518d\u5220)<\/li>\n<li>\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899&#xff1a;<\/li>\n<p>ufw reload<\/p>\n<h5>\u60c5\u51b5 C: \u5982\u679c\u4f7f\u7528\u7684\u662f\u4e91\u670d\u52a1\u5668 (AWS, \u963f\u91cc\u4e91, \u817e\u8baf\u4e91\u7b49)<\/h5>\n<ul>\n<li>\u52a1\u5fc5\u53bb\u4e91\u670d\u52a1\u5546\u7684\u63a7\u5236\u53f0&#xff08;\u7f51\u9875\u7aef&#xff09; &#xff0c;\u627e\u5230\u201c\u5b89\u5168\u7ec4\u201d\u6216\u201c\u9632\u706b\u5899\u201d\u8bbe\u7f6e\u3002<\/li>\n<li>\u6dfb\u52a0\u4e00\u6761\u5165\u7ad9\u89c4\u5219&#xff1a;\u534f\u8bae TCP&#xff0c;\u7aef\u53e3 2222&#xff0c;\u6e90IP 0.0.0.0\/0 (\u6216\u6307\u5b9a\u4f60\u7684IP)\u3002<\/li>\n<li>\u5982\u679c\u4e0d\u505a\u8fd9\u4e00\u6b65&#xff0c;\u5373\u4f7f\u7cfb\u7edf\u5185\u90e8\u9632\u706b\u5899\u5f00\u4e86&#xff0c;\u5916\u90e8\u4e5f\u88ab\u4e91\u5382\u5546\u62e6\u622a\u4e86\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u7b2c\u4e94\u6b65&#xff1a;\u91cd\u542f SSH \u670d\u52a1\u5e76\u9a8c\u8bc1<\/h4>\n<li>\u91cd\u542f \u670d\u52a1&#xff1a;<\/li>\n<p># CentOS \/ RHEL \/ Ubuntu \/ Debian \u901a\u7528<br \/>\nsystemctl restart sshd<\/p>\n<li>\n<p>\u9a8c\u8bc1 (\u5173\u952e\u6b65\u9aa4) &#xff1a;<\/p>\n<li>\u7edd\u5bf9\u4e0d\u8981\u5173\u95ed\u5f53\u524d\u7684 SSH \u7a97\u53e3&#xff01;<\/li>\n<li>\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u7a97\u53e3&#xff08;\u6216\u5728\u4f60\u7684SSH\u5ba2\u6237\u7aef\u5982PuTTY\/Xshell\u4e2d\u65b0\u5efa\u8fde\u63a5&#xff09;\u3002<\/li>\n<li>\u5c1d\u8bd5\u4f7f\u7528\u65b0\u7528\u6237\u548c\u65b0 \u7aef\u53e3\u767b\u5f55&#xff1a;<\/li>\n<\/li>\n<p>ssh -p 2222 adminuser&#064;\u4f60\u7684\u670d\u52a1\u5668IP<\/p>\n<li>\n<p>\u7ed3\u679c\u6d4b\u8bd5&#xff1a;<\/p>\n<li>\u5982\u679c\u80fd\u767b\u5f55\u6210\u529f -&gt; \u606d\u559c&#xff0c;\u914d\u7f6e\u5b8c\u6210\u3002<\/li>\n<li>\u5c1d\u8bd5\u7528 root \u767b\u5f55 -&gt; \u5e94\u8be5\u63d0\u793a \u201cPermission denied\u201d&#xff08;\u88ab\u62d2\u7edd&#xff09;\u3002<\/li>\n<li>\u5982\u679c\u65b0\u7a97\u53e3\u8fde\u63a5\u4e0d\u4e0a -&gt; \u56de\u5230\u539f\u6765\u7684&#xff08;\u672a\u5173\u95ed\u7684&#xff09;\u7a97\u53e3\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u548c\u9632\u706b\u5899&#xff0c;\u628a\u7aef\u53e3\u6539\u56de22&#xff0c;\u91cd\u542f\u670d\u52a1\u4ee5\u6062\u590d\u8bbf\u95ee\u3002<\/li>\n<\/li>\n<h5>\u5386\u53f2\u547d\u4ee4\u8bb0\u5f55\u4f18\u5316&#xff08;\u53ef\u9009&#xff09;<\/h5>\n<p>\u9632\u6b62\u654f\u611f\u4fe1\u606f\u6cc4\u9732\u3002<\/p>\n<ul>\n<li>\u80cc\u666f&#xff1a;\u4f60\u5728\u7ec8\u7aef\u8f93\u5165\u7684\u547d\u4ee4\u4f1a\u88ab\u8bb0\u5f55\u5728 ~\/.bash_history \u4e2d\u3002\u5982\u679c\u4f60\u5728\u547d\u4ee4\u91cc\u5e26\u4e86\u5bc6\u7801&#xff08;\u6bd4\u5982 mysql -u root -p123456&#xff09;&#xff0c;\u8fd9\u975e\u5e38\u5371\u9669\u3002<\/li>\n<li>\u505a\u6cd5&#xff1a; \u5728 \/etc\/profile \u6216 ~\/.bashrc \u4e2d\u8bbe\u7f6e&#xff1a;<\/li>\n<\/ul>\n<p>export HISTTIMEFORMAT&#061;&#034;%F %T &#034;  # \u7ed9\u5386\u53f2\u8bb0\u5f55\u52a0\u65f6\u95f4\u6233&#xff0c;\u65b9\u4fbf\u5ba1\u8ba1<br \/>\nexport HISTCONTROL&#061;ignoreboth   # \u5ffd\u7565\u7a7a\u683c\u5f00\u5934\u7684\u547d\u4ee4<\/p>\n<ul>\n<li>\u6280\u5de7&#xff1a;\u5982\u679c\u4f60\u8981\u8f93\u5165\u654f\u611f\u547d\u4ee4&#xff0c;\u5728\u547d\u4ee4\u6700\u524d\u9762\u52a0\u4e00\u4e2a\u7a7a\u683c&#xff0c;\u8fd9\u6761\u547d\u4ee4\u5c31\u4e0d\u4f1a\u88ab\u8bb0\u5f55\u5230\u5386\u53f2\u6587\u4ef6\u4e2d\u3002<\/li>\n<\/ul>\n<h4>\u603b\u7ed3&#xff1a;\u4e00\u5957\u6807\u51c6\u7684\u52a0\u56fa\u65b9\u6848<\/h4>\n<p>\u5bf9\u4e8e\u5927\u591a\u6570\u751f\u4ea7\u73af\u5883\u670d\u52a1\u5668&#xff0c;\u505a\u5230\u4ee5\u4e0b 4 \u70b9\u901a\u5e38\u5c31\u80fd\u963b\u6321\u7edd\u5927\u90e8\u5206\u7684\u653b\u51fb&#xff1a;<\/p>\n<li>\u975e Root &#043; Sudo<\/li>\n<li>SSH \u6539 \u7aef\u53e3 &#043; \u5bc6\u94a5\u767b\u5f55 &#043; \u7981\u7528\u5bc6\u7801<\/li>\n<li>Fail2Ban \u81ea\u52a8\u5c01\u7981<\/li>\n<li>\u9632\u706b\u5899\u53ea\u5f00\u5fc5\u8981 \u7aef\u53e3<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00<br \/>\n\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u5b83\u4eec\u7684\u6838\u5fc3\u76ee\u7684\u90fd\u662f\u4e3a\u4e86\u589e\u52a0\u653b\u51fb\u8005\u7684\u6210\u672c&#xff0c;\u5e76\u51cf\u5c11\u88ab\u81ea\u52a8\u5316\u811a\u672c\u653b\u7834\u7684\u6982\u7387\u7981\u7528 Root \u7528\u6237\u767b\u5f55<br \/>\n\u589e\u52a0\u66b4\u529b\u7834\u89e3\u7684\u96be\u5ea6&#xff08;\u6700\u4e3b\u8981\u539f\u56e0&#xff09;\u6743\u9650\u5ba1\u8ba1\u4e0e\u8d23\u4efb\u8ffd\u6eaf&#xff08;\u533a\u5206\u56e2\u961f\u7528\u6237&#xff09;\u9632\u6b62\u8bef\u64cd\u4f5c&#xff08;\u6700\u5c0f\u6743\u9650\u539f\u5219&#xff09;\u4fee\u6539 SSH \u9ed8\u8ba4\u7aef\u53e3 (Port 22)<br \/>\n\u89c4\u907f\u81ea\u52a8\u5316\u626b\u63cf\u811a\u672c&#xff08;\u4e3b\u8981\u4f5c\u7528&#xff09;\u4fdd\u6301\/var\/log\/secure\u65e5\u5fd7\u5e72\u51c0\u7b2c\u4e00\u6b65&#xff1a;\u521b\u5efa\u4e00\u4e2a\u62e5<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,61,43,44],"topic":[],"class_list":["post-84361","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux","tag-61","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd - \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\/84361.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00 \u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u5b83\u4eec\u7684\u6838\u5fc3\u76ee\u7684\u90fd\u662f\u4e3a\u4e86\u589e\u52a0\u653b\u51fb\u8005\u7684\u6210\u672c&#xff0c;\u5e76\u51cf\u5c11\u88ab\u81ea\u52a8\u5316\u811a\u672c\u653b\u7834\u7684\u6982\u7387\u7981\u7528 Root \u7528\u6237\u767b\u5f55 \u589e\u52a0\u66b4\u529b\u7834\u89e3\u7684\u96be\u5ea6&#xff08;\u6700\u4e3b\u8981\u539f\u56e0&#xff09;\u6743\u9650\u5ba1\u8ba1\u4e0e\u8d23\u4efb\u8ffd\u6eaf&#xff08;\u533a\u5206\u56e2\u961f\u7528\u6237&#xff09;\u9632\u6b62\u8bef\u64cd\u4f5c&#xff08;\u6700\u5c0f\u6743\u9650\u539f\u5219&#xff09;\u4fee\u6539 SSH \u9ed8\u8ba4\u7aef\u53e3 (Port 22) \u89c4\u907f\u81ea\u52a8\u5316\u626b\u63cf\u811a\u672c&#xff08;\u4e3b\u8981\u4f5c\u7528&#xff09;\u4fdd\u6301\/var\/log\/secure\u65e5\u5fd7\u5e72\u51c0\u7b2c\u4e00\u6b65&#xff1a;\u521b\u5efa\u4e00\u4e2a\u62e5\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/84361.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-26T04:01:56+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84361.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/84361.html\",\"name\":\"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-26T04:01:56+00:00\",\"dateModified\":\"2026-07-26T04:01:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/84361.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/84361.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84361.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd\"}]},{\"@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":"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd - \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\/84361.html","og_locale":"zh_CN","og_type":"article","og_title":"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00 \u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u5b83\u4eec\u7684\u6838\u5fc3\u76ee\u7684\u90fd\u662f\u4e3a\u4e86\u589e\u52a0\u653b\u51fb\u8005\u7684\u6210\u672c&#xff0c;\u5e76\u51cf\u5c11\u88ab\u81ea\u52a8\u5316\u811a\u672c\u653b\u7834\u7684\u6982\u7387\u7981\u7528 Root \u7528\u6237\u767b\u5f55 \u589e\u52a0\u66b4\u529b\u7834\u89e3\u7684\u96be\u5ea6&#xff08;\u6700\u4e3b\u8981\u539f\u56e0&#xff09;\u6743\u9650\u5ba1\u8ba1\u4e0e\u8d23\u4efb\u8ffd\u6eaf&#xff08;\u533a\u5206\u56e2\u961f\u7528\u6237&#xff09;\u9632\u6b62\u8bef\u64cd\u4f5c&#xff08;\u6700\u5c0f\u6743\u9650\u539f\u5219&#xff09;\u4fee\u6539 SSH \u9ed8\u8ba4\u7aef\u53e3 (Port 22) \u89c4\u907f\u81ea\u52a8\u5316\u626b\u63cf\u811a\u672c&#xff08;\u4e3b\u8981\u4f5c\u7528&#xff09;\u4fdd\u6301\/var\/log\/secure\u65e5\u5fd7\u5e72\u51c0\u7b2c\u4e00\u6b65&#xff1a;\u521b\u5efa\u4e00\u4e2a\u62e5","og_url":"https:\/\/www.wsisp.com\/helps\/84361.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-26T04:01:56+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/84361.html","url":"https:\/\/www.wsisp.com\/helps\/84361.html","name":"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-26T04:01:56+00:00","dateModified":"2026-07-26T04:01:56+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/84361.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/84361.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/84361.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u670d\u52a1\u5668\u5b89\u5168\u52a0\u56fa\u57fa\u7840\u63aa\u65bd"}]},{"@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\/84361","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=84361"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84361\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=84361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=84361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=84361"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=84361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}