{"id":218686,"date":"2021-05-29T10:00:03","date_gmt":"2021-05-29T02:00:03","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=218686"},"modified":"2021-05-19T14:58:41","modified_gmt":"2021-05-19T06:58:41","slug":"linux-fuwu-set","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-fuwu-set.html","title":{"rendered":"\u6536\u85cf! Linux \u670d\u52a1\u5668\u5fc5\u5907\u7684\u5b89\u5168\u8bbe\u7f6e"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4e0b\u9762\u544a\u8bc9\u4f60\u4e00\u4e9b\u7b80\u5355\u7684\u65b9\u6cd5\u63d0\u9ad8\u670d\u52a1\u5668\u7684\u5b89\u5168\u7cfb\u6570\uff0c\u6211\u7684\u4e91\u670d\u52a1\u5668\u5c31\u662f\u8fd9\u4e48\u914d\u7f6e\u7684\uff0c\u867d\u7136\u6709\u4e9b\u9ebb\u70e6\uff0c\u4f46\u662f\u611f\u89c9\u5b89\u5fc3\u4e00\u4e9b\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/a><\/p>\n

\u597d\u4e0d\u5bb9\u6613\u4e70\u4e86\u670d\u52a1\u5668\uff0c\u5982\u679c\u56e0\u4e3a\u81ea\u5df1\u7684\u758f\u5ffd\uff0c\u88ab\u9ed1\u5ba2\u9ed1\u6389\u7684\u8bdd\uff0c\u90a3\u771f\u7684\u662f\u592a\u7cdf\u7cd5\u4e86\uff01\u4e0b\u9762\u544a\u8bc9\u4f60\u4e00\u4e9b\u7b80\u5355\u7684\u65b9\u6cd5\u63d0\u9ad8\u670d\u52a1\u5668\u7684\u5b89\u5168\u7cfb\u6570\uff0c\u6211\u7684\u4e91\u670d\u52a1\u5668\u5c31\u662f\u8fd9\u4e48\u914d\u7f6e\u7684\uff0c\u867d\u7136\u6709\u4e9b\u9ebb\u70e6\uff0c\u4f46\u662f\u611f\u89c9\u5b89\u5fc3\u4e00\u4e9b\u3002<\/p>\n

\u4fee\u6539 ssh \u767b\u9646\u914d\u7f6e<\/strong><\/span><\/div>\n

\u6253\u5f00 ssh \u914d\u7f6e\u6587\u4ef6<\/p>\n

vim \/etc\/ssh\/sshd_config\r\n#\u4fee\u6539\u4ee5\u4e0b\u51e0\u9879\r\nPort 10000\r\n#\u66f4\u6539SSH\u7aef\u53e3\uff0c\u6700\u597d\u6539\u4e3a10000\u4ee5\u4e0a\uff0c\u522b\u4eba\u626b\u63cf\u5230\u7aef\u53e3\u7684\u673a\u7387\u4e5f\u4f1a\u4e0b\u964d\u3002\u9632\u706b\u5899\u8981\u5f00\u653e\u914d\u7f6e\u597d\u7684\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u662f\u963f\u91cc\u4e91\u670d\u52a1\u5668\uff0c\u4f60\u8fd8\u9700\u8981\u53bb\u963f\u91cc\u4e91\u540e\u53f0\u914d\u7f6e\u5f00\u53d1\u76f8\u5e94\u7684\u7aef\u53e3\u624d\u53ef\u4ee5\uff0c\u5426\u5219\u767b\u4e0d\u4e0a\u54e6\uff01\u5982\u679c\u4f60\u89c9\u5f97\u9ebb\u70e6\uff0c\u53ef\u4ee5\u4e0d\u7528\u6539\r\nProtocol 2\r\n#\u7981\u7528\u7248\u672c1\u534f\u8bae, \u56e0\u4e3a\u5176\u8bbe\u8ba1\u7f3a\u9677, \u5f88\u5bb9\u6613\u4f7f\u5bc6\u7801\u88ab\u9ed1\u6389\u3002\r\nPermitRootLogin no\r\n#\u5c1d\u8bd5\u4efb\u4f55\u60c5\u51b5\u5148\u90fd\u4e0d\u5141\u8bb8 Root \u767b\u5f55. \u751f\u6548\u540e\u6211\u4eec\u5c31\u4e0d\u80fd\u76f4\u63a5\u4ee5root\u7684\u65b9\u5f0f\u767b\u5f55\u4e86\uff0c\u6211\u4eec\u9700\u8981\u7528\u4e00\u4e2a\u666e\u901a\u7684\u5e10\u53f7\u6765\u767b\u5f55\uff0c\u7136\u540e\u7528su\u6765\u5207\u6362\u5230root\u5e10\u53f7\uff0c\u6ce8\u610f su\u548csu - \u662f\u6709\u4e00\u70b9\u5c0f\u5c0f\u533a\u522b\u7684\u3002\u5173\u952e\u5728\u4e8e\u73af\u5883\u53d8\u91cf\u7684\u4e0d\u540c\uff0csu -\u7684\u73af\u5883\u53d8\u91cf\u66f4\u5168\u9762\u3002\r\nPermitEmptyPasswords no\r\n\uff03\u7981\u6b62\u7a7a\u5bc6\u7801\u767b\u9646\u3002\r\n<\/pre>\n

\u6700\u540e\u9700\u8981\u91cd\u542f sshd \u670d\u52a1<\/p>\n

service sshd restart<\/pre>\n
\u7981\u6b62\u7cfb\u7edf\u54cd\u5e94\u4efb\u4f55\u4ece\u5916\u90e8\/\u5185\u90e8\u6765\u7684ping\u8bf7\u6c42<\/strong><\/span><\/div>\n
echo \u201c1\u201d> \/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all<\/pre>\n

\u5176\u9ed8\u8ba4\u503c\u4e3a 0<\/p>\n

\u7528\u6237\u7ba1\u7406<\/strong><\/span><\/div>\n

\u4e0b\u9762\u662f\u57fa\u672c\u7684\u7528\u6237\u7ba1\u7406\u547d\u4ee4<\/p>\n

\u67e5\u770b\u7528\u6237\u5217\u8868\uff1acat \/etc\/passwd\r\n\u67e5\u770b\u7ec4\u5217\u8868\uff1acat \/etc\/group\r\n\u67e5\u770b\u5f53\u524d\u767b\u9646\u7528\u6237\uff1awho\r\n\u67e5\u770b\u7528\u6237\u767b\u9646\u5386\u53f2\u8bb0\u5f55\uff1alast<\/pre>\n

\u4e00\u822c\u9700\u8981\u5220\u9664\u7cfb\u7edf\u9ed8\u8ba4\u7684\u4e0d\u5fc5\u8981\u7684\u7528\u6237\u548c\u7ec4\uff0c\u907f\u514d\u88ab\u522b\u4eba\u7528\u6765\u7206\u7834\uff1a<\/p>\n

userdel sync\r\nuserdel shutdown\r\n# \u9700\u8981\u5220\u9664\u7684\u591a\u4f59\u7528\u6237\u5171\u6709\uff1async shutdown halt uucp operator games gopher\r\ngroupdel adm\r\ngroupdel games\r\n# \u9700\u8981\u5220\u9664\u7684\u591a\u4f59\u7528\u6237\u7ec4\u5171\u6709\uff1aadm lp games dip<\/pre>\n

Linux\u4e2d\u7684\u5e10\u53f7\u548c\u53e3\u4ee4\u662f\u4f9d\u636e \/etc\/passwd \u3001\/etc\/shadow\u3001 \/etc\/group \u3001\/etc\/gshadow \u8fd9\u56db\u4e2a\u6587\u6863\u7684\uff0c\u6240\u4ee5\u9700\u8981\u66f4\u6539\u5176\u6743\u9650\u63d0\u9ad8\u5b89\u5168\u6027\uff1a<\/p>\n

chattr +i \/etc\/passwd\r\nchattr +i \/etc\/shadow\r\nchattr +i \/etc\/group\r\nchattr +i \/etc\/gshadow<\/pre>\n

\u5982\u679c\u8fd8\u539f\uff0c\u628a +i \u6539\u6210 -i ,\u518d\u6267\u884c\u4e00\u4e0b\u4e0a\u9762\u56db\u6761\u547d\u4ee4\u3002<\/p>\n

\u6ce8\uff1ai\u5c5e\u6027\uff1a\u4e0d\u5141\u8bb8\u5bf9\u8fd9\u4e2a\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\uff0c\u5220\u9664\u6216\u91cd\u547d\u540d\uff0c\u8bbe\u5b9a\u8fde\u7ed3\u4e5f\u65e0\u6cd5\u5199\u5165\u6216\u65b0\u589e\u6570\u636e\uff01\u53ea\u6709 root \u624d\u80fd\u8bbe\u5b9a\u8fd9\u4e2a\u5c5e\u6027\u3002<\/p>\n

\u521b\u5efa\u65b0\u7528\u6237<\/strong><\/span><\/div>\n

\u521b\u5efa\u65b0\u7528\u6237\u547d\u4ee4\uff1aadduser username<\/span><\/p>\n

\u66f4\u6539\u7528\u6237\u5bc6\u7801\u540d\uff1apasswd username<\/span><\/p>\n

\u4e2a\u4eba\u7528\u6237\u7684\u6743\u9650\u53ea\u53ef\u4ee5\u5728\u672chome\u4e0b\u6709\u5b8c\u6574\u6743\u9650\uff0c\u5176\u4ed6\u76ee\u5f55\u8981\u770b\u522b\u4eba\u6388\u6743\u3002\u800c\u7ecf\u5e38\u9700\u8981root\u7528\u6237\u7684\u6743\u9650\uff0c\u8fd9\u65f6\u5019sudo\u53ef\u4ee5\u5316\u8eab\u4e3aroot\u6765\u64cd\u4f5c\u3002\u6211\u8bb0\u5f97\u6211\u66fe\u7ecfsudo\u521b\u5efa\u4e86\u6587\u4ef6\uff0c\u7136\u540e\u53d1\u73b0\u81ea\u5df1\u5e76\u6ca1\u6709\u8bfb\u5199\u6743\u9650\uff0c\u56e0\u4e3a\u67e5\u770b\u6743\u9650\u662froot\u521b\u5efa\u7684\u3002Linux\u7cfb\u7edf\u547d\u4ee4\u8fd8\u662f\u5f88\u91cd\u8981\u7684\uff0c120 \u4e2a\u300a \u5fc5\u77e5\u5fc5\u4f1a\u7684 Linux \u7cfb\u7edf\u5e38\u7528\u547d\u4ee4 \u300b\uff0c\u63a8\u8350\u5927\u5bb6\u770b\u770b\u3002<\/p>\n

sudoers \u53ea\u6709\u53ea\u8bfb\u7684\u6743\u9650\uff0c\u5982\u679c\u60f3\u8981\u4fee\u6539\u7684\u8bdd\uff0c\u9700\u8981\u5148\u6dfb\u52a0w\u6743\u9650\uff1achmod -v u+w \/etc\/sudoers<\/span> \u7136\u540e\u5c31\u53ef\u4ee5\u6dfb\u52a0\u5185\u5bb9\u4e86\uff0c\u5728\u4e0b\u9762\u7684\u4e00\u884c\u4e0b\u8ffd\u52a0\u65b0\u589e\u7684\u7528\u6237\uff1awq<\/span>\u4fdd\u5b58\u9000\u51fa\uff0c\u8fd9\u65f6\u5019\u8981\u8bb0\u5f97\u5c06\u5199\u6743\u9650\u6536\u56de\uff1achmod -v u-w \/etc\/sudoers<\/span><\/p>\n

\u8d4b\u4e88root\u6743\u9650<\/strong><\/span><\/div>\n

\u65b9\u6cd5\u4e00\uff1a\u4fee\u6539 \/etc\/sudoers<\/span> \u6587\u4ef6\uff0c\u627e\u5230\u4e0b\u9762\u4e00\u884c\uff0c\u628a\u524d\u9762\u7684\u6ce8\u91ca\uff08#\uff09\u53bb\u6389<\/p>\n

## Allows people in group wheel to run all commands\r\n# \u53bb\u6389\u4e0b\u9762\u4e00\u53e5\u7684\u524d\u9762\u7684\u6ce8\u91ca #\r\n%wheel ALL=(ALL) ALL\r\n# \u7136\u540e\u4fee\u6539\u7528\u6237\uff0c\u4f7f\u5176\u5c5e\u4e8eroot\u7ec4\uff08wheel\uff09\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a\r\n# usermod -g root uusama<\/pre>\n

\u4fee\u6539\u5b8c\u6bd5\uff0c\u73b0\u5728\u53ef\u4ee5\u7528uusama\u5e10\u53f7\u767b\u5f55\uff0c\u7136\u540e\u7528\u547d\u4ee4 su \u2013 \uff0c\u5373\u53ef\u83b7\u5f97root\u6743\u9650\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n

\u65b9\u6cd5\u4e8c\uff08\u63a8\u8350\uff09\uff1a\u4fee\u6539 \/etc\/sudoers <\/span>\u6587\u4ef6\uff0c\u627e\u5230\u4e0b\u9762\u4e00\u884c\uff0c\u5728root\u4e0b\u9762\u6dfb\u52a0\u4e00\u884c\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

## Allow root to run any commands anywhere\r\nroot ALL=(ALL) ALL\r\nuusama ALL=(ALL) ALL<\/pre>\n

\u4fee\u6539\u5b8c\u6bd5\uff0c\u73b0\u5728\u53ef\u4ee5\u7528uusama\u5e10\u53f7\u767b\u5f55\uff0c\u7136\u540e\u7528\u547d\u4ee4 sudo -s \uff0c\u5373\u53ef\u83b7\u5f97root\u6743\u9650\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n

\u65b9\u6cd5\u4e09\uff1a\u4fee\u6539 \/etc\/passwd<\/span> \u6587\u4ef6\uff0c\u627e\u5230\u5982\u4e0b\u884c\uff0c\u628a\u7528\u6237ID\u4fee\u6539\u4e3a 0 \uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

uusama:x:500:500:tommy:\/home\/uusama:\/bin\/bash\r\n# \u4fee\u6539\u540e\u5982\u4e0b\r\nuusama:x:0:500:tommy:\/home\/uusama:\/bin\/bash<\/pre>\n

\u4fdd\u5b58\uff0c\u7528uusama\u8d26\u6237\u767b\u5f55\u540e\uff0c\u76f4\u63a5\u83b7\u53d6\u7684\u5c31\u662froot\u5e10\u53f7\u7684\u6743\u9650\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u597d\u4e0d\u5bb9\u6613\u4e70\u4e86\u670d\u52a1\u5668\uff0c\u5982\u679c\u56e0\u4e3a\u81ea\u5df1\u7684\u758f\u5ffd\uff0c\u88ab\u9ed1\u5ba2\u9ed1\u6389\u7684\u8bdd\uff0c\u90a3\u771f\u7684\u662f\u592a\u7cdf\u7cd5\u4e86\uff01\u4e0b\u9762\u544a\u8bc9\u4f60\u4e00\u4e9b\u7b80\u5355\u7684\u65b9\u6cd5\u63d0\u9ad8\u670d\u52a1\u5668\u7684 […]<\/p>\n","protected":false},"author":643,"featured_media":218691,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-218686","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\/218686","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\/643"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=218686"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/218686\/revisions"}],"predecessor-version":[{"id":218690,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/218686\/revisions\/218690"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/218691"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=218686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=218686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=218686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}