{"id":48277,"date":"2023-05-07T01:52:37","date_gmt":"2023-05-06T17:52:37","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=48277"},"modified":"2023-05-07T01:52:37","modified_gmt":"2023-05-06T17:52:37","slug":"linux-update-sudo","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-update-sudo.html","title":{"rendered":"\u5982\u4f55\u5728 Linux \u4e2d\u4e0d\u8f93\u5165\u5bc6\u7801\u8fd0\u884c sudo \u547d\u4ee4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5047\u8bbe\u4f60\u5728\u53ea\u6709\u81ea\u5df1\u4f7f\u7528\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c Linux \u7cfb\u7edf\uff0c\u6bd4\u5982\u5728\u7b14\u8bb0\u672c\u7535\u8111\u4e0a\uff0c\u5728\u6bcf\u6b21\u8c03\u7528sudo\u65f6\u9700\u8981\u8f93\u5165\u5bc6\u7801\uff0c\u957f\u671f\u4e0b\u6765\u5c31\u4f1a\u89c9\u5f97\u5f88\u4e4f\u5473\u3002\u56e0\u6b64\uff0c\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u63cf\u8ff0\u5982\u4f55\u914d\u7f6e sudo \u547d\u4ee4\u5728\u8fd0\u884c\u65f6\u800c\u4e0d\u8f93\u5165\u5bc6\u7801\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u6b64\u8bbe\u7f6e\u5728 \/etc\/sudoers<\/span>\u6587\u4ef6\u4e2d\u5b8c\u6210\uff0c\u8fd9\u662f\u4f7f\u7528 sudo \u547d\u4ee4\u7684\u9ed8\u8ba4\u5b89\u5168\u7b56\u7565\uff1b\u5728\u7528\u6237\u6743\u9650\u6307\u5b9a\u90e8\u5206\u3002<\/p>\n

\u91cd\u8981<\/strong>\uff1a\u5728sudeors<\/span>\u6587\u4ef6\u4e2d\uff0c\u9ed8\u8ba4\u6253\u5f00\u7684 authenticate<\/span>\u53c2\u6570\u7528\u4e8e\u9a8c\u8bc1\u76ee\u7684\u3002\u5982\u679c\u8bbe\u7f6e\u4e86\u5b83\uff0c\u7528\u6237\u5fc5\u987b\u901a\u8fc7\u5bc6\u7801\uff08\u6216\u5176\u4ed6\u8eab\u4efd\u9a8c\u8bc1\u65b9\u6cd5\uff09\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\uff0c\u7136\u540e\u624d\u80fd\u4f7f\u7528sudo<\/span>\u8fd0\u884c\u547d\u4ee4\u3002<\/p>\n

\u4f46\u662f\uff0c\u53ef\u4ee5\u4f7f\u7528NOPASSWD<\/span>\uff08\u5f53\u7528\u6237\u8c03\u7528 \"sudo\" \u547d\u4ee4\u65f6\u4e0d\u9700\u8981\u5bc6\u7801\uff09\u6807\u8bb0\u6765\u8986\u76d6\u6b64\u9ed8\u8ba4\u503c\u3002<\/p>\n

\u914d\u7f6e\u7528\u6237\u6743\u9650\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n

    \n
  1. \n
    user_list host_list<\/span>=<\/span>effective_user_list tag_list command_list<\/span><\/pre>\n<\/li>\n<\/ol>\n

    \u5176\u4e2d\uff1a<\/p>\n

      \n
    1. user_list<\/span> - \u7528\u6237\u5217\u8868\u6216\u5df2\u7ecf\u8bbe\u7f6e\u7684\u7528\u6237\u522b\u540d\u3002<\/li>\n
    2. host_list<\/span> - \u4e3b\u673a\u5217\u8868\u6216\u7528\u6237\u53ef\u4ee5\u5728\u5176\u4e0a\u8fd0\u884c sudo \u7684\u4e3b\u673a\u522b\u540d\u3002<\/li>\n
    3. effective_user_list<\/span> - \u4ee5\u8be5\u7528\u6237\u6216\u522b\u540d\u8fd0\u884c\u7684\u7528\u6237\u5217\u8868<\/li>\n
    4. tag_list<\/span> - \u6807\u7b7e\u5217\u8868\uff0c\u5982 NOPASSWD<\/span>\u3002<\/li>\n
    5. command_list<\/span> - \u7528\u6237\u4f7f\u7528sudo<\/span> \u8fd0\u884c\u7684\u547d\u4ee4\u6216\u547d\u4ee4\u522b\u540d\u5217\u8868\u3002<\/li>\n<\/ol>\n

      \u8981\u5141\u8bb8\u7528\u6237\uff08\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\u7684 aaronkilik<\/span>\uff09\u4f7f\u7528 sudo<\/span> \u4e0d\u8f93\u5165\u5bc6\u7801\u5373\u53ef\u8fd0\u884c\u6240\u6709\u547d\u4ee4\uff0c\u8bf7\u6253\u5f00 sudoers<\/span> \u6587\u4ef6\uff1a<\/p>\n

        \n
      1. \n
        $ <\/span>sudo<\/span> visudo<\/span><\/pre>\n<\/li>\n<\/ol>\n

        \u6dfb\u52a0\u4e0b\u9762\u7684\u884c\uff1a<\/p>\n

          \n
        1. \n
          aaronkilik ALL<\/span>=(<\/span>ALL<\/span>)<\/span> NOPASSWD<\/span>:<\/span> ALL<\/span><\/pre>\n<\/li>\n<\/ol>\n

          \u5bf9\u4e8e\u7ec4\u800c\u8a00\uff0c\u5728\u7ec4\u540d\u524d\u9762\u4f7f\u7528 %<\/span> \u5b57\u7b26\uff1b\u8fd9\u610f\u5473\u7740 sys<\/span> \u7ec4\u7684\u6240\u6709\u6210\u5458\u90fd\u53ef\u4ee5\u4e0d\u7528\u5bc6\u7801\u4f7f\u7528 sudo<\/span>\u3002<\/p>\n

            \n
          1. \n
            %<\/span>sys ALL<\/span>=(<\/span>ALL<\/span>)<\/span> NOPASSWD<\/span>:<\/span> ALL<\/span><\/pre>\n<\/li>\n<\/ol>\n

            \u8981\u5141\u8bb8\u7528\u6237\u4e0d\u7528\u5bc6\u7801\u4f7f\u7528 sudo<\/span> \u8fd0\u884c\u6307\u5b9a\u547d\u4ee4\uff08\/bin\/kill<\/span>\uff09\uff0c\u6dfb\u52a0\u4e0b\u9762\u7684\u884c\uff1a<\/p>\n

              \n
            1. \n
              aaronkilik ALL<\/span>=(<\/span>ALL<\/span>)<\/span> NOPASSWD<\/span>:<\/span> \/bin\/<\/span>kill<\/span><\/pre>\n<\/li>\n<\/ol>\n

              \u4e0b\u9762\u7684\u884c\u4f1a\u8ba9 sys<\/span>\u7ec4\u6210\u5458\u5728\u4f7f\u7528 sudo<\/span> \u8fd0\u884c\u547d\u4ee4\uff1a\/bin\/kill<\/span>\u3001\/bin\/rm<\/span> \u65f6\u4e0d\u7528\u8f93\u5165\u5bc6\u7801\uff1a<\/p>\n

                \n
              1. \n
                %<\/span>sys ALL<\/span>=(<\/span>ALL<\/span>)<\/span> NOPASSWD<\/span>:<\/span> \/bin\/<\/span>kill<\/span>,<\/span> \/bin\/<\/span>rm<\/span><\/pre>\n<\/li>\n<\/ol>\n

                \"\u4e0d\u7528\u5bc6\u7801\u8fd0\u884c<\/p>\n

                \u4e0d\u7528\u5bc6\u7801\u8fd0\u884c sudo<\/em><\/p>\n

                \u5728\u672c\u7bc7\u4e2d\uff0c\u6211\u4eec\u8ba8\u8bba\u4e86\u5982\u4f55\u914d\u7f6e sudo \u547d\u4ee4\u6765\u4e0d\u7528\u8f93\u5165\u5bc6\u7801\u8fd0\u884c\u3002\u4e0d\u8981\u5fd8\u8bb0\u5728\u8bc4\u8bba\u680f\u4e2d\u7ed9\u6211\u4eec\u63d0\u4f9b\u4f60\u5173\u4e8e\u8fd9\u4efd\u6307\u5bfc\u7684\u60f3\u6cd5\u548c\u5176\u4ed6\u5bf9\u4e8e Linux \u7cfb\u7edf\u7ba1\u7406\u5458\u6709\u7528\u7684 sudoers \u914d\u7f6e\u3002<\/p>\n

                \n

                \u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-8172-1.html<\/a><\/p>\n

                \u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/linux-update-sudo.html<\/a>\u7f16\u8f91\uff1a\u51af\u742a\uff0c\u5ba1\u6838\u5458\uff1a\u6682\u65e0<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

                \u5bfc\u8bfb \u5047\u8bbe\u4f60\u5728\u53ea\u6709\u81ea\u5df1\u4f7f\u7528\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c Linux \u7cfb\u7edf\uff0c\u6bd4\u5982\u5728\u7b14\u8bb0\u672c\u7535\u8111\u4e0a\uff0c\u5728\u6bcf\u6b21\u8c03\u7528sudo\u65f6\u9700\u8981\u8f93\u5165\u5bc6 […]<\/p>\n","protected":false},"author":63,"featured_media":48282,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-48277","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\/48277","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=48277"}],"version-history":[{"count":8,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/48277\/revisions"}],"predecessor-version":[{"id":271649,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/48277\/revisions\/271649"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/48282"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=48277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=48277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=48277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}