{"id":12553,"date":"2025-04-18T19:42:50","date_gmt":"2025-04-18T11:42:50","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/12553.html"},"modified":"2025-04-18T19:42:50","modified_gmt":"2025-04-18T11:42:50","slug":"debian-12-%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%88%9d%e5%a7%8b%e5%8c%96%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/12553.html","title":{"rendered":"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u4e00\u3001\u670d\u52a1\u5668\u8d2d\u4e70<\/li>\n<li>\u4e8c\u3001\u66f4\u65b0\u5bc6\u7801<\/li>\n<li>\u4e09\u3001\u4fee\u6539ssh\u7aef\u53e3<\/li>\n<li>\u56db\u3001\u9632\u706b\u5899\u914d\u7f6e(ufw)<\/li>\n<li>\u4e94\u3001\u9632\u66b4\u529b\u5165\u4fb5(failban)<\/li>\n<li>\u516d\u3001 root\u767b\u5f55\u5e76\u914d\u7f6e<\/li>\n<li>\u4e03\u3001 \u666e\u901a\u7528\u6237\u914d\u7f6e\u670d\u52a1\u5668<\/li>\n<li>\u516b\u3001 \u4f9d\u8d56\u5b89\u88c5<\/li>\n<li>\u4e5d\u3001 docker\u5b89\u88c5<\/li>\n<li>Reference<\/li>\n<\/ul>\n<p>\u672c\u6587\u4e00 ~ \u516d\u8282\u7684\u547d\u4ee4\u5728root\u7528\u6237\u4e0b\u64cd\u4f5c&#xff0c;\u5982\u5728\u975eroot\u4e0b&#xff0c;\u9700\u6dfb\u52a0sudo\u547d\u4ee4<\/p>\n<h2>\u4e00\u3001\u670d\u52a1\u5668\u8d2d\u4e70<\/h2>\n<p>\u7b14\u8005\u4e91\u670d\u52a1\u5668\u4f7f\u7528\u7684Debian12 \u7cfb\u7edf<\/p>\n<p><span class=\"token function\">cat<\/span> \/etc\/debian_version<br \/>\n<span class=\"token number\">12.0<\/span><\/p>\n<h2>\u4e8c\u3001\u66f4\u65b0\u5bc6\u7801<\/h2>\n<p><span class=\"token function\">passwd<\/span><br \/>\n<span class=\"token comment\"># \u8f93\u5165 new password<\/span><\/p>\n<h2>\u4e09\u3001\u4fee\u6539ssh\u7aef\u53e3<\/h2>\n<p>\u9ed8\u8ba422\u7aef\u53e3\u6781\u6613\u88ab\u653b\u51fb&#xff0c;\u53ef\u6539\u4e3a\u5176\u4ed6\u7aef\u53e3&#xff0c;\u53ef\u4ee5\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u964d\u4f4e\u98ce\u9669\u3002<\/p>\n<p><span class=\"token function\">vim<\/span> \/etc\/ssh\/sshd_config<br \/>\n\u5c06<span class=\"token comment\">#Port 22\u4fee\u6539\u4e3aPort \u7aef\u53e3\u53f7<\/span><br \/>\n<span class=\"token comment\"># \u91cd\u542fssh\u670d\u52a1<\/span><br \/>\n<span class=\"token function\">service<\/span> sshd restart <\/p>\n<h2>\u56db\u3001\u9632\u706b\u5899\u914d\u7f6e(ufw)<\/h2>\n<p>ufw\u662f\u4e3a\u8f7b\u91cf\u5316\u914d\u7f6eiptables\u800c\u5f00\u53d1\u7684\u4e00\u6b3e\u5de5\u5177\u3002\u7b14\u8005\u4f7f\u7528\u8be5\u5de5\u5177\u6765\u914d\u7f6e\u9632\u706b\u5899\u3002\u5177\u4f53\u914d\u7f6e\u5982\u4e0b&#xff1a; 1\u3001\u5b89\u88c5ufw<\/p>\n<p><span class=\"token comment\"># 1\u3001\u5b89\u88c5ufw<\/span><br \/>\n<span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> ufw<\/p>\n<p>2\u3001\u542f\u7528ipv6\u914d\u7f6e \u56e0\u4e3a\u7b14\u8005\u7684\u4e91\u670d\u52a1\u5668\u9ed8\u8ba4\u542f\u7528\u4e86ipv6&#xff0c;\u56e0\u6b64\u9632\u706b\u5899\u914d\u7f6e\u9700\u8981\u540c\u65f6\u5305\u62ecipv4\u548cipv6<\/p>\n<p><span class=\"token function\">vim<\/span> \/etc\/default\/ufw<br \/>\n<span class=\"token comment\"># \u786e\u4fdd IPV6&#061;yes \u8bbe\u7f6e<\/span><\/p>\n<p>3\u3001\u8bbe\u7f6e\u9ed8\u8ba4\u7b56\u7565<\/p>\n<p><span class=\"token comment\"># \u7981\u6b62\u6240\u6709\u5165\u6d41\u91cf<\/span><br \/>\nufw default deny incoming<br \/>\n<span class=\"token comment\"># stdout<\/span><br \/>\nOutput<br \/>\nDefault incoming policy changed to <span class=\"token string\">&#039;deny&#039;<\/span><br \/>\n<span class=\"token punctuation\">(<\/span>be sure to update your rules accordingly<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u5141\u8bb8\u6240\u6709\u51fa\u6d41\u91cf<\/span><br \/>\nufw default allow outgoing<br \/>\n<span class=\"token comment\"># stdout<\/span><br \/>\nOutput<br \/>\nDefault outgoing policy changed to <span class=\"token string\">&#039;allow&#039;<\/span><br \/>\n<span class=\"token punctuation\">(<\/span>be sure to update your rules accordingly<span class=\"token punctuation\">)<\/span><\/p>\n<p>4\u3001\u8bbe\u7f6e\u7279\u6b8a\u7aef\u53e3\u8bbf\u95ee \u5982\u524d\u6587\u4e2d\u4fee\u6539\u7684SSH\u7aef\u53e3<\/p>\n<p>ufw allow <span class=\"token operator\">&lt;<\/span>\u65b0ssh\u7aef\u53e3<span class=\"token operator\">&gt;<\/span><\/p>\n<p>5\u3001\u67e5\u770b\u8bbe\u7f6e\u7684\u89c4\u5219\u5e76\u542f\u52a8ufw<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u89c4\u5219<\/span><br \/>\nufw show added<\/p>\n<p><span class=\"token comment\"># \u542f\u7528\u89c4\u5219<\/span><br \/>\nufw <span class=\"token builtin class-name\">enable<\/span><br \/>\n<span class=\"token comment\"># \u8be5\u6b65\u9aa4\u9700\u8981\u4e8c\u6b21\u786e\u5b9a<\/span><\/p>\n<p>6\u3001\u68c0\u67e5\u89c4\u5219\u8bbe\u7f6e<\/p>\n<p>ufw show added<br \/>\n<span class=\"token comment\"># stdout<\/span><br \/>\nAdded user rules <span class=\"token punctuation\">(<\/span>see <span class=\"token string\">&#039;ufw status&#039;<\/span> <span class=\"token keyword\">for<\/span> running firewall<span class=\"token punctuation\">)<\/span>:<br \/>\nufw allow OpenSSH<br \/>\nufw deny <span class=\"token number\">22<\/span>\/tcp<br \/>\nufw allow <span class=\"token number\">22222<\/span><br \/>\nufw allow <span class=\"token number\">80<\/span>\/tcp<br \/>\nufw deny <span class=\"token number\">22<\/span><br \/>\nroot&#064;york:~<span class=\"token comment\"># ufw status verbose<\/span><br \/>\nStatus: active<br \/>\nLogging: on <span class=\"token punctuation\">(<\/span>low<span class=\"token punctuation\">)<\/span><br \/>\nDefault: deny <span class=\"token punctuation\">(<\/span>incoming<span class=\"token punctuation\">)<\/span>, allow <span class=\"token punctuation\">(<\/span>outgoing<span class=\"token punctuation\">)<\/span>, disabled <span class=\"token punctuation\">(<\/span>routed<span class=\"token punctuation\">)<\/span><br \/>\nNew profiles: skip<\/p>\n<p>To                         Action      From<br \/>\n&#8212;                         &#8212;&#8212;      &#8212;-<br \/>\nxx\/tcp           ALLOW IN    Anywhere<br \/>\nxx\/tcp                     DENY IN     Anywhere<\/p>\n<p>7\u3001\u8bbe\u7f6e\u81ea\u542f\u52a8<\/p>\n<p>systemctl <span class=\"token builtin class-name\">enable<\/span> ufw<\/p>\n<h2>\u4e94\u3001\u9632\u66b4\u529b\u5165\u4fb5(failban)<\/h2>\n<p>fail2ban\u662f\u4e00\u4e2a\u7528\u6765\u9632\u6b62\u7cfb\u7edf\u5165\u4fb5\u7684\u5de5\u5177&#xff0c;\u4e3b\u8981\u662f\u9632\u6b62\u66b4\u529b\u7834\u89e3\u7cfb\u7edf\u5bc6\u7801\u3002 \u867d\u7136\u524d\u6587\u4fee\u6539\u4e86SSH\u7aef\u53e3&#xff0c;\u4f46\u662f\u4ecd\u7136\u6709\u53ef\u80fd\u88ab\u66b4\u529b\u653b\u51fb&#xff0c;\u56e0\u6b64\u7b14\u8005\u7528fail2ban\u6765\u9632\u5fa1\u5bf9SSH\u7684\u66b4\u529b\u7834\u89e3\u3002 1\u3001fail2ban\u5b89\u88c5<\/p>\n<p><span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> fail2ban<\/p>\n<p>2\u3001\u914d\u7f6eSSH\u9632\u5fa1<\/p>\n<p><span class=\"token function\">vim<\/span> \/etc\/fail2ban\/jail.local<br \/>\n<span class=\"token comment\"># \u5185\u5bb9\u5982\u4e0b<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>DEFAULT<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token comment\">#\u6b64\u53c2\u6570\u4e3a\u52a0\u767d\u7684\u7f51\u6bb5\u3001IP&#xff0c;\u53ef\u4ee5\u662f\u57df\u540d\u3001\u7f51\u6bb5\u6216\u5355\u4e2aIP&#xff0c;\u7a7a\u683c\u9694\u5f00\u3002<\/span><br \/>\nignoreip <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">127.0<\/span>.0.1\/8 ::1<\/p>\n<p><span class=\"token comment\">#\u8bbe\u7f6e\u88ab\u5c01\u9501\u7684\u65f6\u95f4\u95f4\u9694&#xff0c;\u5982\u4e0b\u8868\u793a10\u5206\u949f&#xff0c;\u53ef\u4ee5\u662f\u79d2(s)\u3001\u5206\u949f(m)\u3001\u5c0f\u65f6(h)\u3001\u5929(d)&#xff0c;\u4e0d\u5e26\u5355\u4f4d\u5219\u9ed8\u8ba4\u4e3as&#xff0c;-1\u8868\u793a\u6c38\u4e45\u5c01\u9501\u3002<\/span><br \/>\nbantime  <span class=\"token operator\">&#061;<\/span> 10m<\/p>\n<p><span class=\"token comment\">#\u68c0\u6d4b\u7684\u95f4\u9694\u65f6\u95f4&#xff0c;\u5728\u95f4\u9694\u65f6\u95f4\u5185&#xff0c;\u5f53&gt;&#061;maxtretry\u8bbe\u7f6e\u7684\u5931\u8d25\u6b21\u6570&#xff0c;\u5219\u89e6\u53d1\u9650\u5236&#xff0c;\u7981\u6b62\u8bbf\u95ee\u3002<\/span><br \/>\nfindtime  <span class=\"token operator\">&#061;<\/span> 10m<\/p>\n<p><span class=\"token comment\">#findtime\u65f6\u95f4\u5185\u7684\u6700\u5927\u5931\u8d25\u6b21\u6570<\/span><br \/>\nmaxretry <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">5<\/span><\/p>\n<p>backend <span class=\"token operator\">&#061;<\/span> systemd<br \/>\n<span class=\"token punctuation\">[<\/span>sshd<span class=\"token punctuation\">]<\/span><br \/>\nenabled <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><br \/>\nport    <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&lt;<\/span>ssh\u7aef\u53e3<span class=\"token operator\">&gt;<\/span><br \/>\nlogpath <span class=\"token operator\">&#061;<\/span> \/var\/log\/auth.log<br \/>\nbackend <span class=\"token operator\">&#061;<\/span> %<span class=\"token punctuation\">(<\/span>sshd_backend<span class=\"token punctuation\">)<\/span>s<br \/>\nignoreip <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">127.0<\/span>.0.1\/8 ::1 <span class=\"token number\">10.10<\/span>.0.0\/16 <span class=\"token number\">172.16<\/span>.0.0\/16<br \/>\n<span class=\"token comment\"># \u5c01\u9501\u4e00\u4e2a\u6708<\/span><br \/>\nbantime <span class=\"token operator\">&#061;<\/span> 1mon<br \/>\nfindtime <span class=\"token operator\">&#061;<\/span> 2m<br \/>\nmaxretry <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">5<\/span><\/p>\n<p>\u4ee5\u4e0asshd\u914d\u7f6e\u8868\u793a&#xff0c;\u4e24\u5206\u949f\u5185\u5982\u679cssh\u767b\u9646\u5931\u8d25\u4e94\u6b21&#xff0c;\u5219\u5c01\u9501\u8bbf\u95ee\u7684IP&#xff0c;\u540c\u65f6\u6392\u9664\u672c\u5730\u56de\u73af\u5730\u5740\u548c\u4e00\u4e9b\u5185\u7f51\u7f51\u6bb5<\/p>\n<p>PS: \u8c28\u614e\u4f7f\u7528\u5f53\u524d\u914d\u7f6e\u670d\u52a1\u5668\u7684\u673a\u5668\u6765\u6d4b\u8bd5 fail2ban \u5c01\u9501\u529f\u80fd&#xff0c;\u4f1a\u5bfc\u81f4\u65e0\u6cd5\u8bbf\u95ee\u670d\u52a1\u5668&#xff08;\u7b14\u8005\u6df1\u6709\u4f53\u4f1a&#xff09;<\/p>\n<p>3\u3001\u542f\u52a8\u5e76\u8bbe\u7f6e\u81ea\u542f\u52a8<\/p>\n<p><span class=\"token comment\"># \u542f\u52a8<\/span><br \/>\nsystemctl start fail2ban<br \/>\n<span class=\"token comment\"># \u67e5\u770b\u72b6\u6001<\/span><br \/>\nsystemctl status fail2ban<br \/>\n<span class=\"token comment\"># \u81ea\u542f\u52a8<\/span><br \/>\nsystem <span class=\"token builtin class-name\">enable<\/span> fail2ban<\/p>\n<h2>\u516d\u3001 root\u767b\u5f55\u5e76\u914d\u7f6e<\/h2>\n<p>1\u3001\u5728 root \u7528\u6237\u4e0b&#xff0c;\u521b\u5efa\u666e\u901a\u7528\u6237 \u521b\u5efa\u547d\u4ee4<\/p>\n<p>adduser going <span class=\"token comment\"># \u521b\u5efa\u7528\u6237<\/span><br \/>\n<span class=\"token function\">passwd<\/span> going <span class=\"token comment\"># \u8bbe\u7f6e going \u7528\u6237\u7684\u767b\u5f55\u5bc6\u7801<\/span><\/p>\n<p>\u4e00\u822c\u4e00\u4e2a\u9879\u76ee\u7531\u591a\u4e2a\u5f00\u53d1\u4eba\u5458\u5b8c\u6210&#xff0c;\u516c\u53f8\u5e76\u4e0d\u4f1a\u4e3a\u6bcf\u4e2a\u5f00\u53d1\u4eba\u5458\u914d\u7f6e\u4e00\u53f0\u670d\u52a1\u5668&#xff0c;\u800c\u662f\u5171\u7528\u670d\u52a1\u5668&#xff0c;\u901a\u8fc7\u666e\u901a\u7528\u6237\u767b\u5f55\u673a\u5668\u5f00\u53d1\u3002\u5e76\u4e14\u4f7f\u7528\u666e\u901a\u7528\u6237\u767b\u5f55\u548c\u64cd\u4f5c\u5f00\u53d1\u673a\u4e5f\u53ef\u4ee5\u4fdd\u8bc1\u7cfb\u7edf\u7684\u5b89\u5168\u6027<\/p>\n<p>2\u3001\u6dfb\u52a0 sudoers \u6709\u65f6\u5019\u666e\u901a\u7528\u6237\u4e5f\u9700\u8981\u6267\u884c\u4e00\u4e9b\u9700\u8981 root \u6743\u9650\u7684\u64cd\u4f5c&#xff0c;\u4f8b\u5982\u4f7f\u7528 apt \u5b89\u88c5\u4e00\u4e2a\u8f6f\u4ef6\u5305&#xff0c;\u8fd9\u65f6\u5019\u6700\u597d\u7684\u529e\u6cd5\u662f\u5c06\u666e\u901a\u7528\u6237\u6dfb\u52a0\u5230 sudoers \u4e2d&#xff0c;\u8fd9\u6837\u666e\u901a\u7528\u6237\u5c31\u53ef\u4ee5\u901a\u8fc7 sudo \u547d\u4ee4\u6765\u6682\u65f6\u83b7\u53d6 root \u6743\u9650\u3002\u547d\u4ee4\u5982\u4e0b<\/p>\n<p><span class=\"token function\">sed<\/span> <span class=\"token parameter variable\">-i<\/span> <span class=\"token string\">&#039;\/^root.*ALL&#061;(ALL:ALL).*ALL\/a\\\\going\\\\tALL&#061;(ALL:ALL) NOPASSWD: ALL&#039;<\/span> \/etc\/sudoers<\/p>\n<p>\u4e4b\u540e \/etc\/sudoers \u6587\u4ef6\u4e2d&#xff0c;\u65b0\u589e\u4e86\u4ee5\u4e0b\u4e00\u884c<\/p>\n<p>going   <span class=\"token assign-left variable\">ALL<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">(<\/span>ALL:ALL<span class=\"token punctuation\">)<\/span> NOPASSWD: ALL<\/p>\n<p>\/etc\/sudoers \u6587\u4ef6\u7528\u4e8e\u914d\u7f6e sudo&#xff08;superuser do&#xff09;\u547d\u4ee4\u7684\u6388\u6743\u89c4\u5219\u3002sudo \u547d\u4ee4\u5141\u8bb8\u666e\u901a\u7528\u6237\u4ee5\u8d85\u7ea7\u7528\u6237&#xff08;root&#xff09;\u7684\u6743\u9650\u6267\u884c\u7279\u5b9a\u7684\u547d\u4ee4&#xff0c;\u800c\u4e0d\u9700\u8981\u76f4\u63a5\u4f7f\u7528root\u8d26\u6237\u767b\u5f55\u3002 going ALL&#061;(ALL:ALL) NOPASSWD: ALL\u89c4\u5219\u8868\u793a&#xff1a;\u5141\u8bb8\u7528\u6237 going \u5728\u4efb\u4f55\u4e3b\u673a\u4e0a\u4ee5\u4efb\u4f55\u7528\u6237\u7684\u8eab\u4efd\u6267\u884c\u4efb\u4f55\u547d\u4ee4\u65f6\u90fd\u4e0d\u9700\u8981\u8f93\u5165\u5bc6\u7801&#xff0c;\u5373\u53ef\u83b7\u5f97 sudo \u6743\u9650\u3002<\/p>\n<h2>\u4e03\u3001 \u666e\u901a\u7528\u6237\u914d\u7f6e\u670d\u52a1\u5668<\/h2>\n<p>1\u3001\u914d\u7f6e $HOME\/.bashrc \u6587\u4ef6 \u767b\u5f55\u65b0\u670d\u52a1\u5668\u540e\u7684\u7b2c\u4e00\u6b65\u5c31\u662f\u914d\u7f6e $HOME\/.bashrc \u6587\u4ef6&#xff0c;\u4ee5\u4f7f Linux \u767b\u5f55 Shell \u66f4\u52a0\u6613\u7528&#xff0c;\u4f8b\u5982&#xff1a;\u914d\u7f6e LANG \u89e3\u51b3\u4e2d\u6587\u4e71\u7801&#xff1b;\u914d\u7f6e PS1 \u53ef\u4ee5\u4f7f\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u663e\u793a\u66f4\u7b80\u6d01\u3002\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9<\/p>\n<p><span class=\"token comment\"># Some aliases to prevent mistakes<\/span><br \/>\n<span class=\"token builtin class-name\">alias<\/span> <span class=\"token assign-left variable\">rm<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;rm -i&#039;<\/span><br \/>\n<span class=\"token builtin class-name\">alias<\/span> <span class=\"token assign-left variable\">cp<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;cp -i&#039;<\/span><br \/>\n<span class=\"token builtin class-name\">alias<\/span> <span class=\"token assign-left variable\">mv<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;mv -i&#039;<\/span><\/p>\n<p><span class=\"token comment\"># Create a default workspace directory to keep all work files in one place<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token operator\">!<\/span> <span class=\"token parameter variable\">-d<\/span> <span class=\"token environment constant\">$HOME<\/span>\/workspace <span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n    <span class=\"token function\">mkdir<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token environment constant\">$HOME<\/span>\/workspace<br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># User-specific environment settings<\/span><br \/>\n<span class=\"token comment\"># Basic environment<\/span><br \/>\n<span class=\"token comment\"># Set system language to en_US.UTF-8 to avoid Chinese character display issues in the terminal<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\"><span class=\"token environment constant\">LANG<\/span><\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;en_US.UTF-8&#034;<\/span><br \/>\n<span class=\"token comment\"># The default PS1 setting displays the full path, to prevent it from becoming too long, <\/span><br \/>\n<span class=\"token comment\"># it now shows &#034;username&#064;dev last_directory_name&#034;<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\"><span class=\"token environment constant\">PS1<\/span><\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;[\\\\u&#064;dev \\\\W]\\\\$ &#039;<\/span><br \/>\n<span class=\"token comment\"># Set the workspace directory<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">WORKSPACE<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;<span class=\"token environment constant\">$HOME<\/span>\/workspace&#034;<\/span><br \/>\n<span class=\"token comment\"># Add $HOME\/bin directory to the PATH variable<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\"><span class=\"token environment constant\">PATH<\/span><\/span><span class=\"token operator\">&#061;<\/span><span class=\"token environment constant\">$HOME<\/span>\/bin:<span class=\"token environment constant\">$PATH<\/span><br \/>\n<span class=\"token comment\"># Set the default editor to vim<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">EDITOR<\/span><span class=\"token operator\">&#061;<\/span>vim<\/p>\n<p><span class=\"token comment\"># When logging into the system, default to the Workspace directory<\/span><br \/>\n<span class=\"token builtin class-name\">cd<\/span> <span class=\"token variable\">$WORKSPACE<\/span><\/p>\n<p><span class=\"token comment\"># User-specific aliases, configures and functions<\/span><\/p>\n<p>\u4e0a\u8ff0 Bash \u811a\u672c\u4f1a\u81ea\u52a8\u521b\u5efa\u5de5\u4f5c\u76ee\u5f55 workspace&#xff0c;\u4ee5\u540e\u6240\u6709\u7684\u5de5\u4f5c\u90fd\u53ef\u4ee5\u5728\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u5c55\u5f00\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u5e26\u6765\u4ee5\u4e0b\u51e0\u70b9\u597d\u5904&#xff1a;<\/p>\n<ul>\n<li>\u53ef\u4ee5\u4f7f\u6211\u4eec\u7684 $HOME \u76ee\u5f55\u4fdd\u6301\u6574\u6d01&#xff0c;\u4fbf\u4e8e\u4ee5\u540e\u7684\u6587\u4ef6\u67e5\u627e\u548c\u5206\u7c7b&#xff1b;<\/li>\n<li>\u5982\u679c\u54ea\u4e00\u5929 \/ \u5206\u533a\u7a7a\u95f4\u4e0d\u8db3&#xff0c;\u53ef\u4ee5\u5c06\u6574\u4e2a workspace \u76ee\u5f55 mv \u5230\u53e6\u4e00\u4e2a\u5206\u533a\u4e2d&#xff0c;\u5e76\u5728 \/ \u5206\u533a\u4e2d\u4fdd\u7559\u8f6f\u8fde\u63a5&#xff0c;\u4f8b\u5982&#xff1a;\/home\/going\/workspace -&gt; \/data\/workspace\/&#xff1b;<\/li>\n<li>\u5982\u679c\u54ea\u5929\u60f3\u5907\u4efd\u6240\u6709\u7684\u5de5\u4f5c\u6587\u4ef6&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u5907\u4efd workspace\u3002<\/li>\n<\/ul>\n<p>\u5728\u914d\u7f6e PATH \u53d8\u91cf\u65f6&#xff0c;\u5efa\u8bae\u5c06\u671f\u671b\u4f7f\u7528\u7684\u547d\u4ee4\u6240\u5728\u7684\u76ee\u5f55\u653e\u5728 $PATH \u4e4b\u524d&#xff0c;\u8fd9\u6837 Linux \u4f1a\u4f18\u5148\u5339\u914d\u5230\u6211\u4eec\u671f\u671b\u7684\u547d\u4ee4\u3002\u4f8b\u5982&#xff1a;export PATH&#061;$HOME\/bin:$PATH&#xff0c;\u5982\u679c\u6709\u76f8\u540c\u7684\u547d\u4ee4 A&#xff0c;Linux \u4f1a\u4f18\u5148\u4f7f\u7528 $HOME\/bin \u76ee\u5f55\u4e0b\u7684 A<\/p>\n<h2>\u516b\u3001 \u4f9d\u8d56\u5b89\u88c5<\/h2>\n<p>1\u3001\u57fa\u7840\u5de5\u5177\u5b89\u88c5<\/p>\n<p>$ <span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> build-essential jq tclsh gettext <span class=\"token function\">bc<\/span> libcurl4-openssl-dev<\/p>\n<p>2\u3001\u5b89\u88c5Git Git\u662f\u5f53\u524d\u4ee3\u7801\u7ba1\u7406\u5fc5\u4e0d\u53ef\u5c11\u7684\u5de5\u5177&#xff0c;\u7ecf\u8fc7\u5f53\u524d\u5927\u90e8\u5206linux\u673a\u5668\u90fd\u81ea\u5e26git&#xff0c;\u4f46\u662f\u7248\u672c\u8fc7\u4f4e&#xff0c;\u6700\u597d\u5b89\u88c5\u4e00\u4e2a\u9ad8\u7248\u672c\u7684Git\u4ee5\u4f7f\u7528\u5176\u65b0\u7279\u6027\u3002\u5177\u4f53\u5b89\u88c5\u65b9\u6cd5&#xff1a;<\/p>\n<p>$ <span class=\"token builtin class-name\">cd<\/span> \/tmp<br \/>\n$ <span class=\"token function\">wget<\/span> &#8211;no-check-certificate https:\/\/mirrors.edge.kernel.org\/pub\/software\/scm\/git\/git-2.43.0.tar.gz<br \/>\n$ <span class=\"token function\">tar<\/span> <span class=\"token parameter variable\">-xvzf<\/span> git-2.43.0.tar.gz<br \/>\n$ <span class=\"token builtin class-name\">cd<\/span> git-2.43.0\/<br \/>\n$ .\/configure<br \/>\n$ <span class=\"token function\">make<\/span><br \/>\n$ <span class=\"token function\">sudo<\/span> <span class=\"token function\">make<\/span> <span class=\"token function\">install<\/span><br \/>\n$ <span class=\"token function\">git<\/span> <span class=\"token parameter variable\">&#8211;version<\/span> <span class=\"token comment\"># \u8f93\u51fa git \u7248\u672c\u53f7&#xff0c;\u8bf4\u660e\u5b89\u88c5\u6210\u529f<\/span><br \/>\n<span class=\"token function\">git<\/span> version <span class=\"token number\">2.43<\/span>.0<\/p>\n<p>\u5982\u679c\u5728\u6267\u884cmake\u547d\u4ee4\u65f6\u51fa\u73b0\u5982\u4e0b\u9519\u8bef<\/p>\n<p>$ <span class=\"token function\">make<\/span><br \/>\nGIT_VERSION <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2.43<\/span>.0<br \/>\n    * new build flags<br \/>\n    CC oss-fuzz\/fuzz-commit-graph.o<br \/>\nIn <span class=\"token function\">file<\/span> included from oss-fuzz\/fuzz-commit-graph.c:1:<br \/>\n.\/git-compat-util.h:1495:10: fatal error: zlib.h: No such <span class=\"token function\">file<\/span> or directory<br \/>\n <span class=\"token number\">1495<\/span> <span class=\"token operator\">|<\/span> <span class=\"token comment\">#include &lt;zlib.h&gt;<\/span><br \/>\n      <span class=\"token operator\">|<\/span>          ^~~~~~~~<br \/>\ncompilation terminated.<br \/>\nmake: *** <span class=\"token punctuation\">[<\/span>Makefile:2719: oss-fuzz\/fuzz-commit-graph.o<span class=\"token punctuation\">]<\/span> Error <span class=\"token number\">1<\/span><\/p>\n<p>\u6267\u884csudo apt install zlib1g-dev\u547d\u4ee4\u5373\u53ef\u89e3\u51b3\u3002<\/p>\n<p>\u5b89\u88c5\u597d Git \u540e&#xff0c;\u8fd8\u9700\u8981\u628a Git \u7684\u4e8c\u8fdb\u5236\u76ee\u5f55\u6dfb\u52a0\u5230 PATH \u8def\u5f84\u4e2d&#xff0c;\u4e0d\u7136 Git \u53ef\u80fd\u4f1a\u56e0\u4e3a\u627e\u4e0d\u5230\u4e00\u4e9b\u547d\u4ee4\u5bfc\u81f4 Git \u62a5\u9519\u3002\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6dfb\u52a0\u76ee\u5f55&#xff1a;<\/p>\n<p><span class=\"token function\">tee<\/span> <span class=\"token parameter variable\">-a<\/span> <span class=\"token environment constant\">$HOME<\/span>\/.bashrc <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">&#039;EOF&#039;<br \/>\n# Configure for git<br \/>\nexport PATH&#061;\/usr\/local\/libexec\/git-core:$PATH<br \/>\nEOF<\/span><\/p>\n<p>3\u3001\u914d\u7f6eGit<\/p>\n<p>$ <span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> user.name <span class=\"token string\">&#034;xxx&#034;<\/span>    <span class=\"token comment\"># \u7528\u6237\u540d\u6539\u6210\u81ea\u5df1\u7684<\/span><br \/>\n$ <span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> user.email <span class=\"token string\">&#034;xxxx&#064;xxx.com&#034;<\/span>    <span class=\"token comment\"># \u90ae\u7bb1\u6539\u6210\u81ea\u5df1\u7684<\/span><br \/>\n$ <span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> credential.helper store    <span class=\"token comment\"># \u8bbe\u7f6e Git&#xff0c;\u4fdd\u5b58\u7528\u6237\u540d\u548c\u5bc6\u7801<\/span><br \/>\n$ <span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> core.longpaths <span class=\"token boolean\">true<\/span> <span class=\"token comment\"># \u89e3\u51b3 Git \u4e2d &#039;Filename too long&#039; \u7684\u9519\u8bef<\/span><\/p>\n<p>\u9664\u4e86\u4ee5\u4e0a\u914d\u7f6e\u5916&#xff0c;\u8fd8\u6709\u4e00\u4e9b\u6ce8\u610f\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u5728Git\u4e2d&#xff0c;\u4f1a\u628a\u975e ASCII \u5b57\u7b26\u53eb\u505a Unusual \u5b57\u7b26\u3002\u8fd9\u7c7b\u5b57\u7b26\u5728 Git \u8f93\u51fa\u5230\u7ec8\u7aef\u7684\u65f6\u5019\u9ed8\u8ba4\u662f\u7528 8 \u8fdb\u5236\u8f6c\u4e49\u5b57\u7b26\u8f93\u51fa\u7684&#xff08;\u4ee5\u9632\u4e71\u7801&#xff09;&#xff0c;\u4f46\u73b0\u5728\u7684\u7ec8\u7aef\u591a\u6570\u90fd\u652f\u6301\u76f4\u63a5\u663e\u793a\u975e ASCII \u5b57\u7b26&#xff0c;\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5173\u95ed\u6389\u8fd9\u4e2a\u7279\u6027\u3002\u547d\u4ee4\u5982\u4e0b&#xff1a;<\/li>\n<\/ul>\n<p>$ <span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> core.quotepath off<\/p>\n<ul>\n<li>GitHub \u9650\u5236\u6700\u5927\u53ea\u80fd\u514b\u9686 100M \u7684\u5355\u4e2a\u6587\u4ef6&#xff0c;\u4e3a\u4e86\u80fd\u591f\u514b\u9686\u5927\u4e8e 100M \u7684\u6587\u4ef6&#xff0c;\u8fd8\u9700\u8981\u5b89\u88c5 Git Large File Storage<\/li>\n<\/ul>\n<p>$ <span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> git-lfs<\/p>\n<h2>\u4e5d\u3001 docker\u5b89\u88c5<\/h2>\n<p>docker\u662f\u76ee\u524d\u5e02\u573a\u4e0a\u6700\u6d41\u884c\u7684\u5bb9\u5668\u6280\u672f\u4e4b\u4e00&#xff0c;\u5141\u8bb8\u7528\u6237\u5c06\u5e94\u7528\u7a0b\u5e8f\u548c\u670d\u52a1\u6253\u5305\u6210\u72ec\u7acb\u7684\u8fd0\u884c\u65f6\u73af\u5883\u3002\u65b9\u4fbf\u5728\u672c\u5730\u542f\u52a8\u7b2c\u4e09\u65b9\u670d\u52a1\u7528\u4e8e\u6d4b\u8bd5&#xff0c;\u5982mysql&#xff0c;redis\u3002 1\u3001\u5378\u8f7d\u65e7\u7248\u672c<\/p>\n<p><span class=\"token keyword\">for<\/span> <span class=\"token for-or-select variable\">pkg<\/span> <span class=\"token keyword\">in<\/span> docker.io docker-doc <span class=\"token function\">docker-compose<\/span> podman-docker containerd runc<span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">do<\/span> <span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> remove <span class=\"token variable\">$pkg<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">done<\/span><\/p>\n<p>2\u3001\u6dfb\u52a0docker \u5b98\u65b9GPG key<\/p>\n<p><span class=\"token comment\"># Add Docker&#039;s official GPG key:<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> update<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> <span class=\"token function\">install<\/span> ca-certificates <span class=\"token function\">curl<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-m<\/span> 0755 <span class=\"token parameter variable\">-d<\/span> \/etc\/apt\/keyrings<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">curl<\/span> <span class=\"token parameter variable\">-fsSL<\/span> https:\/\/download.docker.com\/linux\/debian\/gpg <span class=\"token parameter variable\">-o<\/span> \/etc\/apt\/keyrings\/docker.asc<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">chmod<\/span> a&#043;r \/etc\/apt\/keyrings\/docker.asc<\/p>\n<p>3\u3001\u5c06\u4ed3\u5e93\u6dfb\u52a0\u5230 APT \u6e90\u4e2d<\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token string\">&#034;deb [arch&#061;<span class=\"token variable\"><span class=\"token variable\">$(<\/span>dpkg &#8211;print-architecture<span class=\"token variable\">)<\/span><\/span> signed-by&#061;\/etc\/apt\/keyrings\/docker.asc] https:\/\/download.docker.com\/linux\/debian \\\\<br \/>\n  <span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token builtin class-name\">.<\/span> \/etc\/os-release <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$VERSION_CODENAME<\/span>&#034;<\/span><span class=\"token variable\">)<\/span><\/span> stable&#034;<\/span> <span class=\"token operator\">|<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token function\">sudo<\/span> <span class=\"token function\">tee<\/span> \/etc\/apt\/sources.list.d\/docker.list <span class=\"token operator\">&gt;<\/span> \/dev\/null<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> update<\/p>\n<p>4\u3001\u5b89\u88c5docker<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> <span class=\"token function\">install<\/span> docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/p>\n<p>\u4e0a\u8ff0\u547d\u4ee4&#xff0c;\u5b89\u88c5\u4e86\u591a\u4e2a Docker \u8f6f\u4ef6\u5305&#xff0c;\u8fd9\u4e9b\u8f6f\u4ef6\u5305\u4f5c\u7528\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>docker-ce&#xff1a;Docker \u793e\u533a\u7248&#xff0c;\u5373 Docker \u7684\u6838\u5fc3\u7a0b\u5e8f&#xff1b;<\/li>\n<li>docker-ce-cli&#xff1a;Docker \u7684\u547d\u4ee4\u884c\u5de5\u5177&#xff1b;<\/li>\n<li>containerd.io&#xff1a;Docker \u7684\u5bb9\u5668\u8fd0\u884c\u65f6&#xff1b;<\/li>\n<li>docker-buildx-plugin&#xff1a;Docker \u591a\u5e73\u53f0\u6784\u5efa\u63d2\u4ef6&#xff1b;<\/li>\n<li>docker-compose-plugin&#xff1a;Docker \u7684\u5bb9\u5668\u7f16\u6392\u5de5\u5177<\/li>\n<\/ul>\n<p>\u5b89\u88c5\u6210\u529f\u4e4b\u540e&#xff0c;\u9ed8\u8ba4 docker \u5904\u5728\u8fd0\u884c\u4e2d\u72b6\u6001&#xff0c;\u53ef\u4ee5\u6267\u884csystemctl status docker\u547d\u4ee4\u67e5\u770b<\/p>\n<p>5\u3001docker\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e docker \u7684\u914d\u7f6e\u6587\u4ef6\u662f \/etc\/docker\/daemon.json&#xff0c;\u8be5\u6587\u4ef6\u4f4d\u4e8e Docker \u914d\u7f6e\u76ee\u5f55\u4e0b&#xff0c;\u901a\u5e38\u662f \/etc\/docker\/ \u76ee\u5f55\u3002\u5982\u679c\u8be5\u6587\u4ef6\u4e0d\u5b58\u5728&#xff0c;\u53ef\u4ee5\u624b\u52a8\u521b\u5efa\u4e00\u4e2a\u6216\u8005\u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u4ee5\u4e0b\u914d\u7f6e&#xff0c;\u8986\u76d6\u5df2\u6709\u7684\u914d\u7f6e<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">tee<\/span> \/etc\/docker\/daemon.json <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">EOF<br \/>\n{<br \/>\n  &#034;exec-opts&#034;: [&#034;native.cgroupdriver&#061;systemd&#034;],<br \/>\n  &#034;insecure-registries&#034;: [],<br \/>\n  &#034;live-restore&#034;: true,<br \/>\n  &#034;bip&#034;: &#034;172.16.0.1\/24&#034;,<br \/>\n  &#034;storage-driver&#034;: &#034;overlay2&#034;,<br \/>\n  &#034;registry-mirrors&#034;: [&#034;https:\/\/registry.docker-cn.com&#034;],<br \/>\n  &#034;data-root&#034;: &#034;\/data\/lib\/docker&#034;,<br \/>\n  &#034;log-driver&#034;: &#034;json-file&#034;,<br \/>\n  &#034;dns&#034;: [],<br \/>\n  &#034;default-runtime&#034;: &#034;runc&#034;,<br \/>\n  &#034;log-opts&#034;: {<br \/>\n    &#034;max-size&#034;: &#034;100m&#034;,<br \/>\n    &#034;max-file&#034;: &#034;10&#034;<br \/>\n  }<br \/>\n}<br \/>\nEOF<\/span><\/p>\n<p>\u914d\u7f6e\u53c2\u6570\u8bf4\u660e\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>exec-opts&#xff1a;\u7528\u4e8e\u914d\u7f6e Docker \u6267\u884c\u65f6\u7684\u9009\u9879\u3002native.cgroupdriver&#061;systemd \u6307\u5b9a\u4f7f\u7528\u7cfb\u7edf\u7684 systemd cgroup \u9a71\u52a8\u7a0b\u5e8f\u3002Cgroup \u63a7\u5236\u7ec4&#xff08;Control Groups&#xff09;\u662f\u4e00\u79cd\u5185\u6838\u529f\u80fd&#xff0c;\u53ef\u4ee5\u9650\u5236\u4e00\u7ec4\u8fdb\u7a0b\u7684\u7cfb\u7edf\u8d44\u6e90\u3002<\/li>\n<li>insecure-registries&#xff1a;\u7528\u4e8e\u914d\u7f6e\u4e0d\u5b89\u5168\u7684\u955c\u50cf\u4ed3\u5e93\u5730\u5740<\/li>\n<li>live-restore&#xff1a;\u662f\u5426\u6062\u590d\u5bb9\u5668\u72b6\u6001\u4ee5\u652f\u6301\u670d\u52a1\u7684\u4e0d\u95f4\u65ad\u66f4\u65b0&#xff0c;\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d&#xff0c;\u8be5\u503c\u4e3a true \u8868\u793a\u542f\u7528\u5bb9\u5668\u72b6\u6001\u6062\u590d\u3002<\/li>\n<li>bip&#xff1a;\u914d\u7f6e Docker \u5bb9\u5668\u7f51\u7edc\u5730\u5740\u7684 IP \u8303\u56f4\u3002\u672c\u4f8b\u4e2d\u8be5\u503c\u4e3a 172.16.0.1\/24 \u8868\u793a\u4f7f\u7528 172.16.0.0\/24 \u5b50\u7f51\u8fdb\u884c Docker \u5bb9\u5668\u901a\u4fe1\u3002<\/li>\n<li>storage-driver&#xff1a;\u7528\u4e8e\u6307\u5b9a\u4f7f\u7528\u7684\u5b58\u50a8\u9a71\u52a8\u3002\u672c\u4f8b\u4e2d\u8be5\u503c\u4e3a overlay2 \u6307\u5b9a\u4f7f\u7528 OverlayFS2 \u5b58\u50a8\u9a71\u52a8\u3002<\/li>\n<li>registry-mirrors&#xff1a;\u7528\u4e8e\u914d\u7f6e Docker \u955c\u50cf\u52a0\u901f\u5668\u5730\u5740\u3002<\/li>\n<li>data-root&#xff1a;\u914d\u7f6e Docker \u7684\u6570\u636e\u5b58\u653e\u8def\u5f84\u3002\u672c\u4f8b\u4e2d\u8be5\u503c\u4e3a \/data\/lib\/docker\u3002<\/li>\n<li>dns&#xff1a;\u914d\u7f6e\u9009\u9879\u7528\u4e8e\u8bbe\u7f6e\u5bb9\u5668\u7684 DNS \u670d\u52a1\u5668\u3002<\/li>\n<li>default-runtime&#xff1a;\u914d\u7f6e\u9009\u9879\u7528\u4e8e\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u8fd0\u884c\u65f6\u3002<\/li>\n<li>log-driver&#xff1a;\u914d\u7f6e Docker \u65e5\u5fd7\u9a71\u52a8\u7a0b\u5e8f\u3002\u672c\u4f8b\u4e2d\u8be5\u503c\u4e3a json-file&#xff0c;\u8868\u793a\u4f7f\u7528 json \u683c\u5f0f\u8bb0\u5f55 Docker \u65e5\u5fd7\u3002<\/li>\n<li>log-opts&#xff1a;\u914d\u7f6e Docker \u65e5\u5fd7\u9009\u9879\u3002\u8be5\u5b57\u6bb5\u662f\u4e00\u4e2a JSON \u5bf9\u8c61&#xff0c;\u5305\u62ec &#xff1a;\n<ul>\n<li>max-size&#xff1a;\u7528\u4e8e\u9650\u5236 Docker \u65e5\u5fd7\u6587\u4ef6\u7684\u6700\u5927\u5927\u5c0f\u3002\u672c\u4f8b\u4e2d\u8be5\u503c\u4e3a 100m&#xff0c;\u8868\u793a Docker \u65e5\u5fd7\u6587\u4ef6\u7684\u5927\u5c0f\u4e0d\u80fd\u5927\u4e8e 100M\u3002\u53ef\u4ee5\u4f7f\u7528 b\u3001k\u3001m\u3001g \u540e\u7f00\u6765\u6307\u5b9a\u5355\u4f4d&#xff08;\u5b57\u8282\u3001\u5343\u5b57\u8282\u3001\u5146\u5b57\u8282\u3001\u5409\u5b57\u8282&#xff09;\u3002<\/li>\n<li>max-file&#xff1a;\u7528\u4e8e\u9650\u5236 Docker \u65e5\u5fd7\u6587\u4ef6\u7684\u6570\u91cf\u3002\u5728\u672c\u4f8b\u4e2d&#xff0c;\u8be5\u503c\u4e3a 10&#xff0c;\u8868\u793a Docker \u53ea\u4f1a\u4fdd\u7559\u6700\u540e10 \u4e2a\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\u9700\u91cd\u542fdocker<\/p>\n<p><span class=\"token function\">sudo<\/span> systemctl restart <span class=\"token function\">docker<\/span><\/p>\n<p>6\u3001docker\u5176\u4ed6\u914d\u7f6e a\u3001\u4f7f\u7528 non-root \u7528\u6237\u64cd\u4f5c docker<\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u914d\u7f6e&#xff0c;\u666e\u901a\u7528\u6237\u8fd0\u884cdocker\u9700\u8981sudo&#xff0c;\u901a\u8fc7\u5982\u4e0b\u914d\u7f6e\u53ef\u5b9e\u73b0\u5728\u975eroot\u4e0b\u6267\u884c\u8fd0\u884c<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token parameter variable\">-i<\/span> <span class=\"token function\">groupadd<\/span> <span class=\"token function\">docker<\/span> <span class=\"token comment\"># \u521b\u5efa &#096;docker&#096; \u7528\u6237\u7ec4<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token parameter variable\">-i<\/span> <span class=\"token function\">usermod<\/span> <span class=\"token parameter variable\">-aG<\/span> <span class=\"token function\">docker<\/span> <span class=\"token environment constant\">$USER<\/span> <span class=\"token comment\"># \u5c06\u5f53\u524d\u7528\u6237\u6dfb\u52a0\u5230 &#096;docker&#096; \u7528\u6237\u7ec4\u4e0b<\/span><br \/>\nnewgrp <span class=\"token function\">docker<\/span> <span class=\"token comment\"># \u91cd\u65b0\u52a0\u8f7d\u7ec4\u6210\u5458\u8eab\u4efd<\/span><br \/>\n<span class=\"token function\">docker<\/span> run hello-world <span class=\"token comment\"># \u786e\u8ba4\u80fd\u591f\u4ee5\u666e\u901a\u7528\u6237\u4f7f\u7528 docker<\/span><\/p>\n<p>b\u3001\u5f00\u673a\u81ea\u542f\u52a8 \u547d\u4ee4\u5982\u4e0b<\/p>\n<p><span class=\"token function\">sudo<\/span> systemctl <span class=\"token builtin class-name\">enable<\/span> docker.service <span class=\"token comment\"># \u8bbe\u7f6e docker \u5f00\u673a\u542f\u52a8<\/span><br \/>\n<span class=\"token function\">sudo<\/span> systemctl <span class=\"token builtin class-name\">enable<\/span> containerd.service <span class=\"token comment\"># \u8bbe\u7f6e containerd \u5f00\u673a\u542f\u52a8<\/span><\/p>\n<h2>Reference<\/h2>\n<ul>\n<li>How to Set Up a Firewall with UFW on Ubuntu<\/li>\n<li>\u4f7f\u7528 fail2ban \u9632\u8303 SSH \u66b4\u529b\u7834\u89e3\u653b\u51fb<\/li>\n<li>Fail2Ban\u5b89\u5168\u914d\u7f6e\u4e0e\u5e94\u7528 &#8211; \u9ad8\u5ea6\u53ef\u5b9a\u5236\u5316\/\u652f\u6301\u591a\u79cd\u670d\u52a1<\/li>\n<li>fail2ban \u542f\u52a8\u5931\u8d25\u95ee\u9898\u5904\u7406<\/li>\n<li>\u77e5\u8bc6\u661f\u7403-\u5b9e\u6218\u8425\u5f00\u53d1\u5b9e\u6218\u8bfe<\/li>\n<li>\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5git<\/li>\n<li>Install Docker Engine on Debian<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb6.1k\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5728Debian12\u7cfb\u7edf\u4e0b\u8d2d\u4e70\u670d\u52a1\u5668\u540e\uff0c\u8fdb\u884c\u5b89\u5168\u589e\u5f3a\u7684\u6b65\u9aa4\uff0c\u5305\u62ec\u4fee\u6539\u5bc6\u7801\uff0c\u8c03\u6574SSH\u7aef\u53e3\uff0c\u914d\u7f6eufw\u9632\u706b\u5899\uff0c\u4ee5\u53ca\u4f7f\u7528fail2ban\u9632\u6b62\u66b4\u529b\u5165\u4fb5\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[402,43,704],"topic":[],"class_list":["post-12553","post","type-post","status-publish","format-standard","hentry","category-server","tag-debian","tag-43","tag-704"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/12553.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb6.1k\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5728Debian12\u7cfb\u7edf\u4e0b\u8d2d\u4e70\u670d\u52a1\u5668\u540e\uff0c\u8fdb\u884c\u5b89\u5168\u589e\u5f3a\u7684\u6b65\u9aa4\uff0c\u5305\u62ec\u4fee\u6539\u5bc6\u7801\uff0c\u8c03\u6574SSH\u7aef\u53e3\uff0c\u914d\u7f6eufw\u9632\u706b\u5899\uff0c\u4ee5\u53ca\u4f7f\u7528fail2ban\u9632\u6b62\u66b4\u529b\u5165\u4fb5\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/12553.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T11:42:50+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12553.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/12553.html\",\"name\":\"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T11:42:50+00:00\",\"dateModified\":\"2025-04-18T11:42:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/12553.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/12553.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12553.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/12553.html","og_locale":"zh_CN","og_type":"article","og_title":"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb6.1k\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5728Debian12\u7cfb\u7edf\u4e0b\u8d2d\u4e70\u670d\u52a1\u5668\u540e\uff0c\u8fdb\u884c\u5b89\u5168\u589e\u5f3a\u7684\u6b65\u9aa4\uff0c\u5305\u62ec\u4fee\u6539\u5bc6\u7801\uff0c\u8c03\u6574SSH\u7aef\u53e3\uff0c\u914d\u7f6eufw\u9632\u706b\u5899\uff0c\u4ee5\u53ca\u4f7f\u7528fail2ban\u9632\u6b62\u66b4\u529b\u5165\u4fb5\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/12553.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T11:42:50+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/12553.html","url":"https:\/\/www.wsisp.com\/helps\/12553.html","name":"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T11:42:50+00:00","dateModified":"2025-04-18T11:42:50+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/12553.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/12553.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/12553.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Debian 12 \u670d\u52a1\u5668\u521d\u59cb\u5316\u914d\u7f6e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=12553"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12553\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=12553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=12553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=12553"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=12553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}