{"id":160144,"date":"2019-10-14T09:45:57","date_gmt":"2019-10-14T01:45:57","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=160144"},"modified":"2019-09-27T17:49:54","modified_gmt":"2019-09-27T09:49:54","slug":"add-bulk-users","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/add-bulk-users.html","title":{"rendered":"\u6559\u4f60\u73a9\u8f6cLinux\u2014\u6dfb\u52a0\u6279\u91cf\u7528\u6237"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6dfb\u52a0\u548c\u5220\u9664\u7528\u6237\u5bf9\u6bcf\u4f4dLinux\u7cfb\u7edf\u7ba1\u7406\u5458\u90fd\u662f\u8f7b\u800c\u6613\u4e3e\u7684\u4e8b\uff0c\u6bd4\u8f83\u68d8\u624b\u7684\u662f\u5982\u679c\u8981\u6dfb\u52a0\u51e0\u5341\u4e2a\u3001\u4e0a\u767e\u4e2a\u751a\u81f3\u4e0a\u5343\u4e2a\u7528\u6237\u65f6\uff0c\u6211\u4eec\u4e0d\u592a\u53ef\u80fd\u8fd8\u4f7f\u7528useradd\u4e00\u4e2a\u4e00\u4e2a\u5730\u6dfb\u52a0\uff0c\u5fc5\u7136\u8981\u627e\u4e00\u79cd\u7b80\u4fbf\u7684\u521b\u5efa\u5927\u91cf\u7528\u6237\u7684\u65b9\u6cd5\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Linux\u7cfb\u7edf\u63d0\u4f9b\u4e86\u521b\u5efa\u5927\u91cf\u7528\u6237\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u8ba9\u60a8\u7acb\u5373\u521b\u5efa\u5927\u91cf\u7528\u6237\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a
\n\"\"<\/p>\n

\uff081\uff09\u5148\u7f16\u8f91\u4e00\u4e2a\u6587\u672c\u7528\u6237\u6587\u4ef6\u3002<\/strong><\/div>\n

\u6bcf\u4e00\u5217\u6309\u7167\/etc\/passwd\u5bc6\u7801\u6587\u4ef6\u7684\u683c\u5f0f\u4e66\u5199\uff0c\u8981\u6ce8\u610f\u6bcf\u4e2a\u7528\u6237\u7684\u7528\u6237\u540d\u3001UID\u3001\u5bbf\u4e3b\u76ee\u5f55\u90fd\u4e0d\u53ef\u4ee5\u76f8\u540c\uff0c\u5176\u4e2d\u5bc6\u7801\u680f\u53ef\u4ee5\u7559\u505a\u7a7a\u767d\u6216\u8f93\u5165x\u53f7\u3002\u4e00\u4e2a\u8303\u4f8b\u6587\u4ef6user.txt\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n

user001::600:100:user:\/home\/user001:\/bin\/bash\r\nuser002::601:100:user:\/home\/user002:\/bin\/bash\r\nuser003::602:100:user:\/home\/user003:\/bin\/bash\r\nuser004::603:100:user:\/home\/user004:\/bin\/bash\r\nuser005::604:100:user:\/home\/user005:\/bin\/bash\r\nuser006::605:100:user:\/home\/user006:\/bin\/bash<\/pre>\n
\uff082\uff09\u4ee5root\u8eab\u4efd\u6267\u884c\u547d\u4ee4 \/usr\/sbin\/newusers\uff0c\u4ece\u521a\u521b\u5efa\u7684\u7528\u6237\u6587\u4ef6user.txt\u4e2d\u5bfc\u5165\u6570\u636e\uff0c\u521b\u5efa\u7528\u6237\uff1a<\/strong><\/div>\n
# newusers < user.txt<\/pre>\n

\u7136\u540e\u53ef\u4ee5\u6267\u884c\u547d\u4ee4 vipw \u6216 vi \/etc\/passwd \u68c0\u67e5 \/etc\/passwd \u6587\u4ef6\u662f\u5426\u5df2\u7ecf\u51fa\u73b0\u8fd9\u4e9b\u7528\u6237\u7684\u6570\u636e\uff0c\u5e76\u4e14\u7528\u6237\u7684\u5bbf\u4e3b\u76ee\u5f55\u662f\u5426\u5df2\u7ecf\u521b\u5efa\u3002<\/p>\n

\uff083\uff09\u6267\u884c\u547d\u4ee4\/usr\/sbin\/pwunconv\u3002<\/strong><\/div>\n

\u5c06 \/etc\/shadow \u4ea7\u751f\u7684 shadow \u5bc6\u7801\u89e3\u7801\uff0c\u7136\u540e\u56de\u5199\u5230 \/etc\/passwd \u4e2d\uff0c\u5e76\u5c06\/etc\/shadow\u7684shadow\u5bc6\u7801\u680f\u5220\u6389\u3002\u8fd9\u662f\u4e3a\u4e86\u65b9\u4fbf\u4e0b\u4e00\u6b65\u7684\u5bc6\u7801\u8f6c\u6362\u5de5\u4f5c\uff0c\u5373\u5148\u53d6\u6d88 shadow password \u529f\u80fd\u3002<\/p>\n

# pwunconv<\/pre>\n
\uff084\uff09\u7f16\u8f91\u6bcf\u4e2a\u7528\u6237\u7684\u5bc6\u7801\u5bf9\u7167\u6587\u4ef6\u3002<\/strong><\/div>\n

\u8303\u4f8b\u6587\u4ef6 passwd.txt \u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n

user001:\u5bc6\u7801\r\nuser002:\u5bc6\u7801\r\nuser003:\u5bc6\u7801\r\nuser004:\u5bc6\u7801\r\nuser005:\u5bc6\u7801\r\nuser006:\u5bc6\u7801<\/pre>\n
\uff085\uff09\u4ee5root\u8eab\u4efd\u6267\u884c\u547d\u4ee4 \/usr\/sbin\/chpasswd\u3002<\/strong><\/div>\n

\u521b\u5efa\u7528\u6237\u5bc6\u7801\uff0cchpasswd \u4f1a\u5c06\u7ecf\u8fc7 \/usr\/bin\/passwd \u547d\u4ee4\u7f16\u7801\u8fc7\u7684\u5bc6\u7801\u5199\u5165 \/etc\/passwd \u7684\u5bc6\u7801\u680f\u3002<\/p>\n

# chpasswd < passwd.txt<\/pre>\n
\uff086\uff09\u786e\u5b9a\u5bc6\u7801\u7ecf\u7f16\u7801\u5199\u5165\/etc\/passwd\u7684\u5bc6\u7801\u680f\u540e\u3002<\/strong><\/div>\n

\u6267\u884c\u547d\u4ee4 \/usr\/sbin\/pwconv \u5c06\u5bc6\u7801\u7f16\u7801\u4e3a shadow password\uff0c\u5e76\u5c06\u7ed3\u679c\u5199\u5165 \/etc\/shadow\u3002<\/p>\n

# pwconv<\/pre>\n

\u8fd9\u6837\u5c31\u5b8c\u6210\u4e86\u5927\u91cf\u7528\u6237\u7684\u521b\u5efa\u4e86\uff0c\u4e4b\u540e\u60a8\u53ef\u4ee5\u5230\/home\u4e0b\u68c0\u67e5\u8fd9\u4e9b\u7528\u6237\u5bbf\u4e3b\u76ee\u5f55\u7684\u6743\u9650\u8bbe\u7f6e\u662f\u5426\u90fd\u6b63\u786e\uff0c\u5e76\u767b\u5f55\u9a8c\u8bc1\u7528\u6237\u5bc6\u7801\u662f\u5426\u6b63\u786e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Linux\u7cfb\u7edf\u63d0\u4f9b\u4e86\u521b\u5efa\u5927\u91cf\u7528\u6237\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u8ba9\u60a8\u7acb\u5373\u521b\u5efa\u5927\u91cf\u7528\u6237\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a \u6bcf\u4e00\u5217\u6309\u7167\/etc\/passwd […]<\/p>\n","protected":false},"author":1481,"featured_media":160251,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-160144","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\/160144","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\/1481"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=160144"}],"version-history":[{"count":8,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160144\/revisions"}],"predecessor-version":[{"id":160309,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160144\/revisions\/160309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/160251"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=160144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=160144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=160144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}