{"id":165349,"date":"2019-12-18T11:44:12","date_gmt":"2019-12-18T03:44:12","guid":{"rendered":"https:\/\/gulass.cn\/?p=165349"},"modified":"2019-11-27T09:45:12","modified_gmt":"2019-11-27T01:45:12","slug":"sudo-permission-view","status":"publish","type":"post","link":"https:\/\/gulass.cn\/sudo-permission-view.html","title":{"rendered":"sudo\u6743\u9650\u7528\u6237\u67e5\u770b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6559\u7a0b\u5c06\u8bb2\u89e3\u5982\u4f55\u67e5\u770bLinux\u7528\u6237\u662f\u5426\u6709sudo\u6743\u9650\u3002\u60a8\u8fd8\u5c06\u5b66\u4e60\u5982\u4f55\u67e5\u770bLinux\u7cfb\u7edf\u4e0a\u7684\u6240\u6709sudo\u7528\u6237\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u60f3\u77e5\u9053\u60a8\u5f53\u524d\u7684\u7528\u6237\u5728\u7cfb\u7edf\u4e0a\u662f\u5426\u6709sudo\u6743\u9650?\u5f88\u5bb9\u6613\u9a8c\u8bc1\u3002\u53ea\u8981\u7528sudo\u8fd0\u884c\u4efb\u4f55\u547d\u4ee4\u3002\u5982\u679c\u4f60\u6ca1\u6709sudo\u6743\u9650\uff0c\u4f60\u5e94\u8be5\u5728\u8f93\u51fa\u4e2d\u770b\u5230\uff1a<\/p>\n

\r\noucanrong@zcwyou:~$ sudo -v\r\n<\/pre>\n

\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n

\r\nSorry, user standard may not run sudo on linuxhandbook. \r\n<\/pre>\n

\u90a3\u5f88\u9177!\u4f46\u662f\u5982\u679c\u68c0\u67e5\u5176\u4ed6\u7528\u6237\u662f\u5426\u62e5\u6709sudo\u6743\u9650\u5462?\u4f60\u4e5f\u5b8c\u5168\u53ef\u4ee5\u505a\u5230\u3002\u6211\u6765\u6559\u4f60\u600e\u4e48\u505a\u3002<\/p>\n

1. \u5982\u4f55\u6d4b\u8bd5\u7528\u6237\u662f\u5426\u5177\u6709sudo\u6743\u9650<\/strong><\/div>\n

\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u68c0\u67e5Linux\u7528\u6237\u662f\u5426\u53ef\u4ee5\u4f7f\u7528sudo\u3002\u672c\u6587\u4ecb\u7ecd\u4e00\u4e9b\u3002<\/p>\n

(1) \u65b9\u6cd51: \u4f7f\u7528sudo\u547d\u4ee4\u67e5\u770b\u7528\u6237\u662f\u5426\u662fsudoer<\/strong><\/span><\/div>\n

sudo\u547d\u4ee4\u672c\u8eab\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9009\u9879\u6765\u67e5\u770b\u7528\u6237\u662f\u5426\u53ef\u4ee5\u4f7f\u7528sudo\u8fd0\u884c\u547d\u4ee4\u3002\u5b9e\u9645\u4e0a\uff0c\u5b83\u544a\u8bc9\u60a8\u67d0\u4e2a\u7528\u6237\u53ef\u4ee5\u4f7f\u7528sudo\u8fd0\u884c\u54ea\u4e9b\u547d\u4ee4\u3002<\/p>\n

\u4f7f\u7528sudo\u547d\u4ee4\u67e5\u770b\u7528\u6237\u662f\u5426\u662fsudoer<\/p>\n

\u8981\u68c0\u67e5\u7528\u6237\u7684sudo\u8bbf\u95ee\u6743\u9650\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4:<\/p>\n

\u5047\u8bbe\u7528\u6237\u540d\u4e3auser_name<\/p>\n

\r\nsudo -l -U user_name\r\n<\/pre>\n

\u5982\u679c\u7528\u6237\u53ef\u4ee5\u7528sudo\u8fd0\u884c\u4e00\u4e9b\u6216\u6240\u6709\u547d\u4ee4\uff0c\u60a8\u5e94\u8be5\u4f1a\u770b\u5230\u8fd9\u6837\u7684\u8f93\u51fa\uff1a<\/p>\n

\r\nMatching Defaults entries for abhi on test-server: \r\n    env_reset, mail_badpass, \r\n    secure_path=\/usr\/local\/sbin\\:\/usr\/local\/bin\\:\/usr\/sbin\\:\/usr\/bin\\:\/sbin\\:\/bin\\:\/snap\/bin \r\n \r\nUser zcwyou may run the following commands on test-server: \r\n    (ALL : ALL) NOPASSWD: ALL\r\n<\/pre>\n

\u5982\u4e0a\u8ff0\u8f93\u51fa\u7ed3\u679c\uff0c\u7528\u6237zcwyou\u53ef\u4ee5\u901a\u8fc7sudo\u8bbf\u95ee\u8fd0\u884c\u6240\u6709\u547d\u4ee4\u3002\u5982\u679c\u7528\u6237\u6ca1\u6709sudo\u6743\u9650\uff0c\u60a8\u5e94\u8be5\u770b\u5230\u8fd9\u6837\u7684\u8f93\u51fa\uff1a<\/p>\n

\r\nUser zcwyou is not allowed to run sudo on test-server. \r\n<\/pre>\n

\u5982\u679c\u60a8\u60f3\u67e5\u770b\u7528\u6237\u662f\u5426\u62e5\u6709sudo\u6743\u9650\u4ee5\u53ca\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9b\u547d\u4ee4\u8fd0\u884csudo\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u547d\u4ee4\uff0c\u4f46\u4e0d\u8981\u63d0\u4f9b\u7528\u6237\u540d\u3002<\/p>\n

\r\nsudo -l \r\n<\/pre>\n
(2) \u65b9\u6cd52: \u67e5\u770b\u7528\u6237\u662f\u5426\u5c5e\u4e8e`sudo`\u7ec4<\/strong><\/span><\/div>\n

\u53e6\u4e00\u79cd\u786e\u5b9a\u7528\u6237\u662f\u5426\u5177\u6709sudo\u8bbf\u95ee\u6743\u9650\u7684\u65b9\u6cd5\u662f\u67e5\u770b\u8be5\u7528\u6237\u662f\u5426\u662fsudo\u7ec4\u7684\u6210\u5458\u3002<\/p>\n

\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u67e5\u770bLinux\u4e2d\u7528\u6237\u7684\u7ec4\u3002\u6700\u7b80\u5355\u4e5f\u662f\u6211\u6700\u559c\u6b22\u7684\u65b9\u6cd5\u662f\u8fd9\u6837\u4f7f\u7528groups\u547d\u4ee4\uff1a<\/p>\n

\u5047\u8bbe\u8981\u67e5\u770buser_name\u8fd9\u4e2a\u7528\u6237\u7684\u5bf9\u5e94\u7684\u7ec4<\/p>\n

\r\ngroups user_name \r\n<\/pre>\n

\u5982\u679c\u60a8\u5728\u8f93\u51fa\u4e2d\u770b\u5230\u7ec4sudo\uff0c\u5219\u7528\u6237\u662fsudo\u7ec4\u7684\u6210\u5458\uff0c\u5e94\u8be5\u5177\u6709sudo\u8bbf\u95ee\u6743\u3002<\/p>\n

\r\noucanrong@zcwyou:~$ groups ocr \r\nocr : ocr sudo\r\n<\/pre>\n
(3) \u989d\u5916\u63d0\u793a:\u5982\u4f55\u5728\u60a8\u7684\u7cfb\u7edf\u4e2d\u67e5\u770b\u6240\u6709sudo\u7528\u6237<\/strong><\/span><\/div>\n

\u4f60\u5df2\u7ecf\u5b66\u4f1a\u4e86\u5982\u4f55\u67e5\u770b\u7528\u6237\u662f\u5426\u6709sudo\u8bbf\u95ee\u6743\u9650\u3002\u600e\u4e48\u6837\u5728Linux\u7cfb\u7edf\u4e2d\u5217\u51fa\u6240\u6709sudoers\u6587\u4ef6?<\/p>\n

\u989d\u5916\u63d0\u793a:\u5982\u4f55\u5728\u60a8\u7684\u7cfb\u7edf\u4e2d\u67e5\u770b\u6240\u6709sudo\u7528\u6237<\/p>\n

\u5982\u679c\u60a8\u5df2\u7ecf\u9605\u8bfb\u4e86\u672c\u6587\uff0c\u7b54\u6848\u5f88\u7b80\u5355\u3002\u60a8\u6240\u9700\u8981\u505a\u7684\u5c31\u662f\u5217\u51fasudo\u7ec4\u7684\u6210\u5458\u3002<\/p>\n

\u5728Linux\u4e2d\uff0c\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u76f8\u540c\u7684\u7ed3\u679c\u3002\u8fd9\u4e0d\u5947\u602a\uff0c\u5728Linux\u4e2d\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5217\u51fa\u7ec4\u7684\u6210\u5458\u3002<\/p>\n

\u82e5\u8981\u5217\u51fa\u7cfb\u7edf\u7684\u6240\u6709sudo\u7528\u6237\uff0c\u8bf7\u6309\u4ee5\u4e0b\u65b9\u5f0f\u5217\u51fasudo\u7ec4\u7684\u6210\u5458:<\/p>\n

\r\ngetent group sudo \r\n<\/pre>\n

\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u7cfb\u7edf\u4e0a\u62e5\u6709sudo\u6743\u9650\u7684\u6240\u6709\u7528\u6237:<\/p>\n

\r\ngetent group sudo \r\n<\/pre>\n

\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n

\r\nsudo:x:27:ocr,zcwyou \r\n<\/pre>\n

\u5c31\u8fd9\u6837\u7b80\u5355\u3002\u6211\u5e0c\u671b\u60a8\u73b0\u5728\u80fd\u77e5\u9053\u5982\u4f55\u67e5\u770b\u60a8\u81ea\u5df1\u662f\u5426\u62e5\u6709sudo\u6743\u9650\u6216\u5176\u4ed6\u7528\u6237\u662f\u5426\u62e5\u6709sudo\u6743\u9650\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u60f3\u77e5\u9053\u60a8\u5f53\u524d\u7684\u7528\u6237\u5728\u7cfb\u7edf\u4e0a\u662f\u5426\u6709sudo\u6743\u9650?\u5f88\u5bb9\u6613\u9a8c\u8bc1\u3002\u53ea\u8981\u7528sudo\u8fd0\u884c\u4efb\u4f55\u547d\u4ee4\u3002\u5982\u679c\u4f60\u6ca1\u6709sudo\u6743\u9650\uff0c […]<\/p>\n","protected":false},"author":1329,"featured_media":165351,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-165349","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/165349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=165349"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/165349\/revisions"}],"predecessor-version":[{"id":165352,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/165349\/revisions\/165352"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/165351"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=165349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=165349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=165349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}