{"id":216148,"date":"2021-04-26T10:48:13","date_gmt":"2021-04-26T02:48:13","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=216148"},"modified":"2021-04-16T14:48:34","modified_gmt":"2021-04-16T06:48:34","slug":"gey-linux-seurt","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/gey-linux-seurt.html","title":{"rendered":"\u5982\u4f55\u63d0\u5347 Linux \u670d\u52a1\u5668\u5b89\u5168\u7684\u5f00\u6e90\u5de5\u5177\u548c\u6280\u5de7\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u57fa\u4e8e\u6211\u4f5c\u4e3a\u521d\u5b66\u8005\u8fc4\u4eca\u6240\u5b66\u7684\u77e5\u8bc6\uff0c\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u516d\u4e2a\u7b80\u5355\u7684\u6b65\u9aa4\uff0c\u4ee5\u63d0\u9ad8\u4e2a\u4eba\u4f7f\u7528\u7684 Linux \u73af\u5883\u7684\u5b89\u5168\u6027\u3002\u5728\u6211\u7684\u6574\u4e2a\u65c5\u7a0b\u4e2d\uff0c\u6211\u5229\u7528\u5f00\u6e90\u5de5\u5177\u6765\u52a0\u901f\u6211\u7684\u5b66\u4e60\u8fc7\u7a0b\uff0c\u5e76\u719f\u6089\u4e86\u4e0e\u63d0\u5347 Linux \u670d\u52a1\u5668\u5b89\u5168\u6709\u5173\u7684\u66f4\u9ad8\u5c42\u6b21\u7684\u6982\u5ff5\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5982\u4eca\u6211\u4eec\u7684\u8bb8\u591a\u4e2a\u4eba\u548c\u4e13\u4e1a\u6570\u636e\u90fd\u53ef\u4ee5\u5728\u7f51\u4e0a\u83b7\u5f97\uff0c\u56e0\u6b64\u65e0\u8bba\u662f\u4e13\u4e1a\u4eba\u58eb\u8fd8\u662f\u666e\u901a\u4e92\u8054\u7f51\u7528\u6237\uff0c\u5b66\u4e60\u5b89\u5168\u548c\u9690\u79c1\u7684\u57fa\u672c\u77e5\u8bc6\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4f5c\u4e3a\u4e00\u540d\u5b66\u751f\uff0c\u6211\u901a\u8fc7\u5b66\u6821\u7684 CyberPatriot \u6d3b\u52a8\u83b7\u5f97\u4e86\u8fd9\u65b9\u9762\u7684\u7ecf\u9a8c\uff0c\u5728\u90a3\u91cc\u6211\u6709\u673a\u4f1a\u4e0e\u884c\u4e1a\u4e13\u5bb6\u4ea4\u6d41\uff0c\u4e86\u89e3\u7f51\u7edc\u6f0f\u6d1e\u548c\u5efa\u7acb\u7cfb\u7edf\u5b89\u5168\u7684\u57fa\u672c\u6b65\u9aa4\u3002<\/p>\n

\u6211\u4f7f\u7528\u6211\u6700\u719f\u6089\u7684 Ubuntu 18.04 \u7248\u672c\u6d4b\u8bd5\u4e86\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4f46\u8fd9\u4e9b\u6b65\u9aa4\u4e5f\u9002\u7528\u4e8e\u5176\u4ed6 Linux \u53d1\u884c\u7248\u3002<\/p>\n

1\u3001\u8fd0\u884c\u66f4\u65b0<\/strong><\/div>\n

\u5f00\u53d1\u8005\u4eec\u4e0d\u65ad\u5730\u5bfb\u627e\u65b9\u6cd5\uff0c\u901a\u8fc7\u4fee\u8865\u5df2\u77e5\u7684\u6f0f\u6d1e\uff0c\u4f7f\u670d\u52a1\u5668\u66f4\u52a0\u7a33\u5b9a\u3001\u5feb\u901f\u3001\u5b89\u5168\u3002\u5b9a\u671f\u8fd0\u884c\u66f4\u65b0\u662f\u4e00\u4e2a\u597d\u4e60\u60ef\uff0c\u53ef\u4ee5\u6700\u5927\u9650\u5ea6\u5730\u63d0\u9ad8\u5b89\u5168\u6027\u3002\u8fd0\u884c\u5b83\u4eec\uff1a<\/p>\n

sudo apt-get update && apt-get upgrade<\/pre>\n
2\u3001\u542f\u7528\u9632\u706b\u5899\u4fdd\u62a4<\/strong><\/div>\n

\u542f\u7528\u9632\u706b\u5899 \u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u63a7\u5236\u670d\u52a1\u5668\u4e0a\u7684\u8fdb\u7ad9\u548c\u51fa\u7ad9\u6d41\u91cf\u3002\u5728 Linux \u4e0a\u6709\u8bb8\u591a\u9632\u706b\u5899\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u4f7f\u7528\uff0c\u5305\u62ec firewall-cmd \u548c \u7b80\u5355\u9632\u706b\u5899Uncomplicated Firewall\uff08UFW\uff09\u3002\u6211\u4f7f\u7528 UFW\uff0c\u6240\u4ee5\u6211\u7684\u4f8b\u5b50\u662f\u4e13\u95e8\u9488\u5bf9\u5b83\u7684\uff0c\u4f46\u8fd9\u4e9b\u539f\u5219\u9002\u7528\u4e8e\u4f60\u9009\u62e9\u7684\u4efb\u4f55\u9632\u706b\u5899\u3002<\/p>\n

\u5b89\u88c5 UFW\uff1a<\/p>\n

sudo apt-get install ufw<\/pre>\n

\u5982\u679c\u4f60\u60f3\u8fdb\u4e00\u6b65\u4fdd\u62a4\u4f60\u7684\u670d\u52a1\u5668\uff0c\u4f60\u53ef\u4ee5\u62d2\u7edd\u4f20\u5165\u548c\u4f20\u51fa\u7684\u8fde\u63a5\u3002\u8bf7\u6ce8\u610f\uff0c\u8fd9\u5c06\u5207\u65ad\u4f60\u7684\u670d\u52a1\u5668\u4e0e\u4e16\u754c\u7684\u8054\u7cfb\uff0c\u6240\u4ee5\u4e00\u65e6\u4f60\u5c01\u9501\u4e86\u6240\u6709\u7684\u6d41\u91cf\uff0c\u4f60\u5fc5\u987b\u6307\u5b9a\u54ea\u4e9b\u51fa\u7ad9\u8fde\u63a5\u662f\u5141\u8bb8\u4ece\u4f60\u7684\u7cfb\u7edf\u4e2d\u53d1\u51fa\u7684\uff1a<\/p>\n

sudo ufw default deny incoming\r\n\r\nsudo ufw default allow outgoing<\/pre>\n

\u4f60\u4e5f\u53ef\u4ee5\u7f16\u5199\u89c4\u5219\u6765\u5141\u8bb8\u4f60\u4e2a\u4eba\u4f7f\u7528\u6240\u9700\u8981\u7684\u4f20\u5165\u8fde\u63a5\uff1a<\/p>\n

ufw allow <service><\/pre>\n

\u4f8b\u5982\uff0c\u5141\u8bb8 SSH \u8fde\u63a5\uff1a<\/p>\n

ufw allow ssh<\/pre>\n

\u6700\u540e\uff0c\u542f\u7528\u4f60\u7684\u9632\u706b\u5899\uff1a<\/p>\n

sudo ufw enable<\/pre>\n
3\u3001\u52a0\u5f3a\u5bc6\u7801\u4fdd\u62a4<\/strong><\/div>\n

\u5b9e\u65bd\u5f3a\u6709\u529b\u7684\u5bc6\u7801\u653f\u7b56\u662f\u4fdd\u6301\u670d\u52a1\u5668\u5b89\u5168\u3001\u9632\u6b62\u7f51\u7edc\u653b\u51fb\u548c\u6570\u636e\u6cc4\u9732\u7684\u4e00\u4e2a\u91cd\u8981\u65b9\u9762\u3002\u5bc6\u7801\u7b56\u7565\u7684\u4e00\u4e9b\u6700\u4f73\u5b9e\u8df5\u5305\u62ec\u5f3a\u5236\u8981\u6c42\u6700\u5c0f\u957f\u5ea6\u548c\u6307\u5b9a\u5bc6\u7801\u5e74\u9f84\u3002\u6211\u4f7f\u7528 libpam-cracklib \u8f6f\u4ef6\u5305\u6765\u5b8c\u6210\u8fd9\u4e9b\u4efb\u52a1\u3002<\/p>\n

\u5b89\u88c5 libpam-cracklib \u8f6f\u4ef6\u5305\uff1a<\/p>\n

sudo apt-get install libpam-cracklib<\/pre>\n

\u5f3a\u5236\u8981\u6c42\u5bc6\u7801\u7684\u957f\u5ea6\uff1a<\/p>\n

    \n
  • \u6253\u5f00 \/etc\/pam.d\/common-password\u00a0\u6587\u4ef6\u3002<\/li>\n
  • \u5c06 minlen=12\u00a0\u884c\u6539\u4e3a\u4f60\u9700\u8981\u7684\u4efb\u610f\u5b57\u7b26\u6570\uff0c\u4ece\u800c\u6539\u53d8\u6240\u6709\u5bc6\u7801\u7684\u6700\u5c0f\u5b57\u7b26\u957f\u5ea6\u8981\u6c42\u3002<\/li>\n<\/ul>\n

    \u4e3a\u9632\u6b62\u5bc6\u7801\u91cd\u590d\u4f7f\u7528\uff1a<\/p>\n

      \n
    • \u5728\u540c\u4e00\u4e2a\u6587\u4ef6\uff08\/etc\/pam.d\/common-password\uff09\u4e2d\uff0c\u6dfb\u52a0\u00a0remember=x\u00a0\u884c\u3002<\/li>\n
    • \u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u9632\u6b62\u7528\u6237\u91cd\u590d\u4f7f\u7528\u4ed6\u4eec\u6700\u540e 5 \u4e2a\u5bc6\u7801\u4e2d\u7684\u4e00\u4e2a\uff0c\u4f7f\u7528 remember=5\u3002<\/li>\n<\/ul>\n

      \u8981\u5f3a\u5236\u8981\u6c42\u5bc6\u7801\u5e74\u9f84\uff1a<\/p>\n

        \n
      • \u5728 \/etc\/login.defs\u00a0\u6587\u4ef6\u4e2d\u627e\u5230\u4ee5\u4e0b\u51e0\u884c\uff0c\u5e76\u7528\u4f60\u559c\u6b22\u7684\u65f6\u95f4\uff08\u5929\u6570\uff09\u66ff\u6362\u3002<\/li>\n<\/ul>\n

        \u5f3a\u5236\u8981\u6c42\u5b57\u7b26\u89c4\u683c\uff1a<\/p>\n

          \n
        • \u5728\u5bc6\u7801\u4e2d\u5f3a\u5236\u8981\u6c42\u5b57\u7b26\u89c4\u683c\u7684\u56db\u4e2a\u53c2\u6570\u662f lcredit\uff08\u5c0f\u5199\uff09\u3001ucredit\uff08\u5927\u5199\uff09\u3001dcredit\uff08\u6570\u5b57\uff09\u548c\u00a0ocredit\uff08\u5176\u4ed6\u5b57\u7b26\uff09\u3002<\/li>\n
        • \u5728\u540c\u4e00\u4e2a\u6587\u4ef6\uff08\/etc\/pam.d\/common-password\uff09\u4e2d\uff0c\u627e\u5230\u5305\u542b\u00a0pam_cracklib.so\u00a0\u7684\u884c\u3002\n
            \n
          • \u5728\u8be5\u884c\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1alcredit=-a ucredit=-b dcredit=-c ocredit=-d\u3002<\/li>\n
          • \u4f8b\u5982\uff0c\u4e0b\u9762\u8fd9\u884c\u8981\u6c42\u5bc6\u7801\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a\u6bcf\u79cd\u5b57\u7b26\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u4f60\u559c\u6b22\u7684\u5bc6\u7801\u5b89\u5168\u7ea7\u522b\u6765\u6539\u53d8\u6570\u5b57\u3002lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n
            4\u3001\u505c\u7528\u5bb9\u6613\u88ab\u5229\u7528\u7684\u975e\u5fc5\u8981\u670d\u52a1\u3002<\/strong><\/div>\n

            \u505c\u7528\u4e0d\u5fc5\u8981\u7684\u670d\u52a1\u662f\u4e00\u79cd\u6700\u597d\u7684\u505a\u6cd5\u3002\u8fd9\u6837\u53ef\u4ee5\u51cf\u5c11\u5f00\u653e\u7684\u7aef\u53e3\uff0c\u4ee5\u4fbf\u88ab\u5229\u7528\u3002<\/p>\n

            \u5b89\u88c5 systemd \u8f6f\u4ef6\u5305\uff1a<\/p>\n

            sudo apt-get install systemd<\/pre>\n

            \u67e5\u770b\u54ea\u4e9b\u670d\u52a1\u6b63\u5728\u8fd0\u884c\uff1a<\/p>\n

            systemctl list-units<\/pre>\n

            \u8bc6\u522b\u00a0\u54ea\u4e9b\u670d\u52a1\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4f60\u7684\u7cfb\u7edf\u51fa\u73b0\u6f5c\u5728\u7684\u6f0f\u6d1e\u3002\u5bf9\u4e8e\u6bcf\u4e2a\u670d\u52a1\u53ef\u4ee5\uff1a<\/p>\n

              \n
            • \u505c\u6b62\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\uff1asystemctl stop <service>\u3002<\/li>\n
            • \u7981\u6b62\u670d\u52a1\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u542f\u52a8\uff1asystemctl disable <service>\u3002<\/li>\n
            • \u8fd0\u884c\u8fd9\u4e9b\u547d\u4ee4\u540e\uff0c\u68c0\u67e5\u670d\u52a1\u7684\u72b6\u6001\uff1asystemctl status <service>\u3002<\/li>\n<\/ul>\n
              5\u3001\u68c0\u67e5\u76d1\u542c\u7aef\u53e3<\/strong><\/div>\n

              \u5f00\u653e\u7684\u7aef\u53e3\u53ef\u80fd\u4f1a\u5e26\u6765\u5b89\u5168\u98ce\u9669\uff0c\u6240\u4ee5\u68c0\u67e5\u670d\u52a1\u5668\u4e0a\u7684\u76d1\u542c\u7aef\u53e3\u5f88\u91cd\u8981\u3002\u6211\u4f7f\u7528\u00a0netstat\u00a0\u547d\u4ee4\u6765\u663e\u793a\u6240\u6709\u7684\u7f51\u7edc\u8fde\u63a5\uff1a<\/p>\n

              netstat -tulpn<\/pre>\n

              \u67e5\u770b \u201caddress\u201d \u5217\uff0c\u786e\u5b9a\u00a0\u7aef\u53e3\u53f7\u3002\u4e00\u65e6\u4f60\u627e\u5230\u4e86\u5f00\u653e\u7684\u7aef\u53e3\uff0c\u68c0\u67e5\u5b83\u4eec\u662f\u5426\u90fd\u662f\u5fc5\u8981\u7684\u3002\u5982\u679c\u4e0d\u662f\uff0c\u8c03\u6574\u4f60\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\uff0c\u6216\u8005\u8c03\u6574\u4f60\u7684\u9632\u706b\u5899\u8bbe\u7f6e\u3002<\/p>\n

              6\u3001\u626b\u63cf\u6076\u610f\u8f6f\u4ef6<\/strong><\/div>\n

              \u6740\u6bd2\u626b\u63cf\u8f6f\u4ef6\u53ef\u4ee5\u6709\u7528\u7684\u9632\u6b62\u75c5\u6bd2\u8fdb\u5165\u4f60\u7684\u7cfb\u7edf\u3002\u4f7f\u7528\u5b83\u4eec\u662f\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8ba9\u4f60\u7684\u670d\u52a1\u5668\u514d\u53d7\u6076\u610f\u8f6f\u4ef6\u7684\u4fb5\u5bb3\u3002\u6211\u9996\u9009\u7684\u5de5\u5177\u662f\u5f00\u6e90\u8f6f\u4ef6\u00a0ClamAV\u3002
              \n\u5b89\u88c5 ClamAV\uff1a<\/p>\n

              sudo apt-get install clamav<\/pre>\n

              \u66f4\u65b0\u75c5\u6bd2\u7b7e\u540d\uff1a<\/p>\n

              sudo freshclam<\/pre>\n

              \u626b\u63cf\u6240\u6709\u6587\u4ef6\uff0c\u5e76\u6253\u5370\u51fa\u88ab\u611f\u67d3\u7684\u6587\u4ef6\uff0c\u53d1\u73b0\u4e00\u4e2a\u5c31\u4f1a\u54cd\u94c3\uff1a<\/p>\n

              sudo clamscan -r --bell -i \/<\/pre>\n

              \u4f60\u53ef\u4ee5\u800c\u4e14\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u81ea\u52a8\u626b\u63cf\uff0c\u8fd9\u6837\u4f60\u5c31\u4e0d\u5fc5\u8bb0\u4f4f\u6216\u82b1\u65f6\u95f4\u624b\u52a8\u8fdb\u884c\u626b\u63cf\u3002\u5bf9\u4e8e\u8fd9\u6837\u7b80\u5355\u7684\u81ea\u52a8\u5316\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u00a0systemd \u5b9a\u65f6\u5668\u00a0\u6216\u8005\u4f60\u7684\u00a0\u559c\u6b22\u7684 cron\u00a0\u6765\u505a\u5230\u3002<\/p>\n

              7\u3001\u4fdd\u8bc1\u4f60\u7684\u670d\u52a1\u5668\u5b89\u5168<\/strong><\/div>\n

              \u6211\u4eec\u4e0d\u80fd\u628a\u4fdd\u62a4\u670d\u52a1\u5668\u5b89\u5168\u7684\u8d23\u4efb\u53ea\u4ea4\u7ed9\u4e00\u4e2a\u4eba\u6216\u4e00\u4e2a\u7ec4\u7ec7\u3002\u968f\u7740\u5a01\u80c1\u73af\u5883\u7684\u4e0d\u65ad\u8fc5\u901f\u6269\u5927\uff0c\u6211\u4eec\u6bcf\u4e2a\u4eba\u90fd\u5e94\u8be5\u610f\u8bc6\u5230\u670d\u52a1\u5668\u5b89\u5168\u7684\u91cd\u8981\u6027\uff0c\u5e76\u91c7\u7528\u4e00\u4e9b\u7b80\u5355\u3001\u6709\u6548\u7684\u5b89\u5168\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n

              \u8fd9\u4e9b\u53ea\u662f\u4f60\u63d0\u5347 Linux \u670d\u52a1\u5668\u7684\u5b89\u5168\u53ef\u4ee5\u91c7\u53d6\u7684\u4f17\u591a\u6b65\u9aa4\u4e2d\u7684\u4e00\u90e8\u5206\u3002\u5f53\u7136\uff0c\u9884\u9632\u53ea\u662f\u89e3\u51b3\u65b9\u6848\u7684\u4e00\u90e8\u5206\u3002\u8fd9\u4e9b\u7b56\u7565\u5e94\u8be5\u4e0e\u4e25\u683c\u76d1\u63a7\u62d2\u7edd\u670d\u52a1\u653b\u51fb\u3001\u7528\u00a0Lynis\u00a0\u505a\u7cfb\u7edf\u5206\u6790\u4ee5\u53ca\u521b\u5efa\u9891\u7e41\u7684\u5907\u4efd\u76f8\u7ed3\u5408\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

              \u5982\u4eca\u6211\u4eec\u7684\u8bb8\u591a\u4e2a\u4eba\u548c\u4e13\u4e1a\u6570\u636e\u90fd\u53ef\u4ee5\u5728\u7f51\u4e0a\u83b7\u5f97\uff0c\u56e0\u6b64\u65e0\u8bba\u662f\u4e13\u4e1a\u4eba\u58eb\u8fd8\u662f\u666e\u901a\u4e92\u8054\u7f51\u7528\u6237\uff0c\u5b66\u4e60\u5b89\u5168\u548c\u9690\u79c1\u7684\u57fa\u672c\u77e5\u8bc6\u662f […]<\/p>\n","protected":false},"author":323,"featured_media":208904,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-216148","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=216148"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216148\/revisions"}],"predecessor-version":[{"id":216154,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216148\/revisions\/216154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/208904"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=216148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=216148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=216148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}