{"id":210662,"date":"2026-02-04T19:33:41","date_gmt":"2026-02-04T11:33:41","guid":{"rendered":"https:\/\/server.hk\/cnblog\/?p=210662"},"modified":"2026-02-05T19:34:45","modified_gmt":"2026-02-05T11:34:45","slug":"ubuntu-%e7%b3%bb%e7%bb%9f%e5%9c%a8%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%8e%af%e5%a2%83%e4%b8%ad%e7%9a%84%e4%bd%bf%e7%94%a8%e4%b8%8e%e8%bf%90%e7%bb%b4","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/210662\/","title":{"rendered":"Ubuntu \u7cfb\u7edf\u5728\u670d\u52a1\u5668\u73af\u5883\u4e2d\u7684\u4f7f\u7528\u4e0e\u8fd0\u7ef4"},"content":{"rendered":"<p dir=\"auto\">Ubuntu Server \u662f\u5f53\u4eca\u4e91\u539f\u751f\u3001Web \u670d\u52a1\u3001\u6570\u636e\u5e93\u3001\u5bb9\u5668\u5316\u90e8\u7f72\u7b49\u9886\u57df\u6700\u53d7\u6b22\u8fce\u7684 Linux \u53d1\u884c\u7248\u4e4b\u4e00\u3002\u51ed\u501f Debian \u7cfb\u7684\u7a33\u5b9a\u57fa\u7840\u3001\u5e9e\u5927\u7684\u8f6f\u4ef6\u751f\u6001\u3001Canonical \u63d0\u4f9b\u7684\u957f\u671f\u652f\u6301\uff08LTS\uff09\uff0c\u4ee5\u53ca\u4e0e AWS\u3001Azure\u3001GCP \u7b49\u4e91\u5e73\u53f0\u7684\u6df1\u5ea6\u9002\u914d\uff0c\u5b83\u5df2\u6210\u4e3a\u8bb8\u591a\u4f01\u4e1a\u548c\u4e2a\u4eba\u7684\u9996\u9009\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p dir=\"auto\">\u672c\u6587\u4ece\u670d\u52a1\u5668\u89c6\u89d2\u51fa\u53d1\uff0c\u7cfb\u7edf\u68b3\u7406 Ubuntu \u5728\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u6838\u5fc3\u4f7f\u7528\u65b9\u5f0f\u3001\u5e38\u89c1\u8fd0\u7ef4\u5b9e\u8df5\u548c\u6700\u4f73\u5b9e\u8df5\u3002\u5185\u5bb9\u57fa\u4e8e 2026 \u5e74\u521d\u4e3b\u6d41\u73b0\u72b6\uff08\u5f53\u524d LTS \u7248\u672c\u4e3a Ubuntu 24.04 LTS \u201cNoble Numbat\u201d\uff0c\u652f\u6301\u81f3 2029 \u5e74\u6807\u51c6\u7ef4\u62a4 + ESM \u6269\u5c55\u81f3 2034\/2039 \u5e74\uff1bUbuntu 26.04 LTS \u9884\u8ba1 2026 \u5e74 4 \u6708\u53d1\u5e03\uff09\u3002<\/p>\n<h3 dir=\"auto\">\u4e00\u3001\u4e3a\u4ec0\u4e48\u9009\u62e9 Ubuntu Server<\/h3>\n<ul dir=\"auto\">\n<li><strong>\u957f\u671f\u652f\u6301\u5468\u671f\u957f<\/strong>\uff1aLTS \u7248\u672c\u6807\u51c6 5 \u5e74\u514d\u8d39\u5b89\u5168\u66f4\u65b0\uff0cUbuntu Pro\uff08\u514d\u8d39\u4e2a\u4eba\/\u5c0f\u56e2\u961f\uff0c\u4ed8\u8d39\u4f01\u4e1a\uff09\u53ef\u6269\u5c55\u81f3 10 \u5e74 ESM\uff0c\u751a\u81f3\u901a\u8fc7 Legacy add-on \u8fbe\u5230 15 \u5e74\u603b\u751f\u547d\u5468\u671f\u3002\u9002\u5408\u4e0d\u613f\u9891\u7e41\u5347\u7ea7\u7684\u751f\u4ea7\u73af\u5883\u3002<\/li>\n<li><strong>\u6700\u5c0f\u5316\u5b89\u88c5 + \u4e91\u53cb\u597d<\/strong>\uff1a\u5b98\u65b9\u63d0\u4f9b cloud-init\u3001\u9884\u914d\u7f6e\u955c\u50cf\uff0cminimal install \u955c\u50cf\u4f53\u79ef\u5c0f\u3001\u653b\u51fb\u9762\u4f4e\u3002<\/li>\n<li><strong>\u73b0\u4ee3\u5de5\u5177\u6808<\/strong>\uff1asystemd\u3001netplan\u3001snap\/ apt\u3001LXD\/Incus\u3001MicroK8s \u7b49\u539f\u751f\u652f\u6301\uff0c\u5bb9\u5668\/\u865a\u62df\u5316\/\u7f16\u6392\u751f\u6001\u5b8c\u6574\u3002<\/li>\n<li><strong>\u793e\u533a + \u4f01\u4e1a\u53cc\u8f6e\u9a71\u52a8<\/strong>\uff1a\u6d77\u91cf\u6559\u7a0b\u3001\u8bba\u575b\u6d3b\u8dc3\uff0c\u540c\u65f6 Canonical \u63d0\u4f9b Ubuntu Pro \/ Landscape \u7b49\u4f01\u4e1a\u7ea7\u5de5\u5177\u3002<\/li>\n<\/ul>\n<h3 dir=\"auto\">\u4e8c\u3001\u5b89\u88c5\u4e0e\u521d\u59cb\u914d\u7f6e\uff08\u751f\u4ea7\u73af\u5883\u63a8\u8350\u6d41\u7a0b\uff09<\/h3>\n<ol dir=\"auto\">\n<li><strong>\u4e0b\u8f7d\u4e0e\u4ecb\u8d28\u51c6\u5907<\/strong> \u4f18\u5148\u9009\u62e9\u5b98\u65b9 minimal ISO\uff08ubuntu-24.04.3-live-server-amd64.iso \u6216\u66f4\u65b0\u70b9\u7248\u672c\uff09\u3002\u4e91\u4e0a\u76f4\u63a5\u7528 Marketplace \u955c\u50cf\u3002<\/li>\n<li><strong>\u5b89\u88c5\u9009\u9879\u5173\u952e\u70b9<\/strong>\n<ul dir=\"auto\">\n<li>\u9009\u62e9 <strong>Minimal installation<\/strong>\uff08\u6781\u7b80\u5b89\u88c5\uff09<\/li>\n<li>\u542f\u7528 <strong>OpenSSH server<\/strong>\uff08\u540e\u7eed\u901a\u8fc7\u5bc6\u94a5\u767b\u5f55\uff09<\/li>\n<li>\u78c1\u76d8\u5206\u533a\uff1a\u63a8\u8350 LVM + ext4\uff08\u6216 xfs\/btrfs\uff09\uff0c\/boot \u5355\u72ec 1GB\uff0c\/ \u5269\u4f59\u7a7a\u95f4\uff0c\u8003\u8651\u5355\u72ec \/var \/home<\/li>\n<li>\u8bbe\u7f6e\u5f3a\u5bc6\u7801 + \u521b\u5efa\u666e\u901a\u7528\u6237\uff08\u52a0\u5165 sudo \u7ec4\uff09\uff0c<strong>\u7981\u7528 root \u5bc6\u7801\u767b\u5f55<\/strong><\/li>\n<\/ul>\n<\/li>\n<li><strong>\u9996\u6b21\u767b\u5f55\u540e\u7acb\u5373\u6267\u884c<\/strong>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Bash<\/div>\n<div>\n<div>\n<div><\/div>\n<\/div>\n<\/div>\n<div>\n<pre tabindex=\"0\"><code>sudo apt update &amp;&amp; sudo apt upgrade -y\r\nsudo apt install htop curl wget git net-tools unzip -y\r\nsudo reboot<\/code><\/pre>\n<\/div>\n<div><\/div>\n<\/div>\n<div><\/div>\n<\/div>\n<\/div>\n<\/li>\n<li><strong>SSH \u5b89\u5168\u52a0\u56fa\uff08\u5fc5\u505a\uff09<\/strong>\n<ul dir=\"auto\">\n<li>\u7f16\u8f91 \/etc\/ssh\/sshd_config\uff1a\n<ul dir=\"auto\">\n<li>PermitRootLogin no<\/li>\n<li>PasswordAuthentication no\uff08\u6539\u7528\u5bc6\u94a5\uff09<\/li>\n<li>PubkeyAuthentication yes<\/li>\n<li>Port 2222\uff08\u53ef\u9009\u6539\u7aef\u53e3\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\u751f\u6210\u5bc6\u94a5\u5bf9\uff1assh-keygen -t ed25519<\/li>\n<li>\u590d\u5236\u516c\u94a5\uff1assh-copy-id user@ip<\/li>\n<li>\u91cd\u542f ssh\uff1asudo systemctl restart ssh<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3 dir=\"auto\">\u4e09\u3001\u65e5\u5e38\u8fd0\u7ef4\u6838\u5fc3\u9886\u57df<\/h3>\n<h4 dir=\"auto\">1. \u5305\u7ba1\u7406\u4e0e\u66f4\u65b0\u7b56\u7565<\/h4>\n<ul dir=\"auto\">\n<li><strong>\u65e5\u5e38\u7ef4\u62a4<\/strong>\uff1asudo apt update &amp;&amp; sudo apt full-upgrade -y &amp;&amp; sudo apt autoremove<\/li>\n<li><strong>\u81ea\u52a8\u5b89\u5168\u66f4\u65b0<\/strong>\uff08\u5f3a\u70c8\u63a8\u8350\u751f\u4ea7\u73af\u5883\uff09\uff1a\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Bash<\/div>\n<div>\n<div>\n<div><\/div>\n<\/div>\n<\/div>\n<div>\n<pre tabindex=\"0\"><code>sudo apt install unattended-upgrades -y\r\nsudo dpkg-reconfigure --priority=low unattended-upgrades<\/code><\/pre>\n<\/div>\n<div><\/div>\n<\/div>\n<div><\/div>\n<\/div>\n<\/div>\n<p>\u542f\u7528\u540e\uff0c\u9ed8\u8ba4\u53ea\u81ea\u52a8\u5b89\u88c5\u5b89\u5168\u8865\u4e01\u3002<\/li>\n<li><strong>needrestart<\/strong>\uff1a\u5b89\u88c5\u540e\u68c0\u67e5\u5185\u6838\/\u5e93\u66f4\u65b0\u662f\u5426\u9700\u8981\u91cd\u542f\u670d\u52a1\/\u7cfb\u7edf\u3002<\/li>\n<li><strong>Ubuntu Pro<\/strong>\uff1a\u514d\u8d39\u6ce8\u518c\u542f\u7528\uff0c\u83b7\u5f97 Universe \u4ed3\u5e93 10 \u5e74 ESM + Livepatch\uff08\u65e0\u91cd\u542f\u5185\u6838\u8865\u4e01\uff09\u3002<\/li>\n<\/ul>\n<h4 dir=\"auto\">2. \u670d\u52a1\u7ba1\u7406\uff08systemd\uff09<\/h4>\n<ul dir=\"auto\">\n<li>systemctl status\/enable\/start\/stop\/restart \u670d\u52a1\u540d<\/li>\n<li>journalctl -u \u670d\u52a1\u540d -f\uff08\u5b9e\u65f6\u65e5\u5fd7\uff09<\/li>\n<li>journalctl &#8211;vacuum-time=60d\uff08\u5b9a\u671f\u6e05\u7406\u65e5\u5fd7\u5360\u7528\uff09<\/li>\n<\/ul>\n<h4 dir=\"auto\">3. \u7f51\u7edc\u914d\u7f6e\uff08\u73b0\u4ee3 netplan\uff09<\/h4>\n<p dir=\"auto\">\u914d\u7f6e\u6587\u4ef6\u5728 \/etc\/netplan\/\uff0c\u793a\u4f8b\u9759\u6001 IP\uff1a<\/p>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>YAML<\/div>\n<div>\n<div>\n<div><\/div>\n<\/div>\n<\/div>\n<div>\n<pre tabindex=\"0\"><code>network:\r\n  version: 2\r\n  renderer: networkd\r\n  ethernets:\r\n    enp1s0:\r\n      dhcp4: no\r\n      addresses: [192.168.1.10\/24]\r\n      gateway4: 192.168.1.1\r\n      nameservers:\r\n        addresses: [8.8.8.8, 1.1.1.1]<\/code><\/pre>\n<\/div>\n<div><\/div>\n<\/div>\n<div><\/div>\n<\/div>\n<\/div>\n<p dir=\"auto\">\u5e94\u7528\uff1asudo netplan apply<\/p>\n<p dir=\"auto\">\u9632\u706b\u5899\uff1a\u63a8\u8350 ufw\uff08\u7b80\u5355\uff09\u6216 nftables\uff08\u9ad8\u7ea7\uff09<\/p>\n<ul dir=\"auto\">\n<li>sudo ufw allow OpenSSH<\/li>\n<li>sudo ufw allow 80,443\/tcp<\/li>\n<li>sudo ufw enable<\/li>\n<\/ul>\n<h4 dir=\"auto\">4. \u78c1\u76d8\u4e0e\u5b58\u50a8<\/h4>\n<ul dir=\"auto\">\n<li>df -h \/ df -i\uff08\u7a7a\u95f4 &amp; inode\uff09<\/li>\n<li>lsblk -f\uff08\u67e5\u770b\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\uff09<\/li>\n<li>\u76d1\u63a7\u5de5\u5177\uff1a\u5b89\u88c5 smartmontools + ncdu\uff08\u4ea4\u4e92\u5f0f du\uff09<\/li>\n<li>\u5907\u4efd\uff1arsync + cron\uff0c\u6216 restic\/borg \u5230\u8fdc\u7a0b<\/li>\n<\/ul>\n<h4 dir=\"auto\">5. \u5b89\u5168\u52a0\u56fa\uff082026 \u5e74\u6700\u4f73\u5b9e\u8df5\uff09<\/h4>\n<ul dir=\"auto\">\n<li>\u6700\u5c0f\u5316\u5b89\u88c5 \u2192 \u51cf\u5c11\u653b\u51fb\u9762<\/li>\n<li>fail2ban\uff08\u9632\u66b4\u529b\u7834\u89e3\uff09<\/li>\n<li>apparmor \/ selinux\uff08\u53ef\u9009\u5f3a\u5316\uff09<\/li>\n<li>\u5b9a\u671f\u626b\u63cf\uff1alynis \/ debsecan<\/li>\n<li>\u5bc6\u94a5 + MFA\uff08Google Authenticator\uff09<\/li>\n<li>\u5173\u95ed\u4e0d\u5fc5\u8981\u670d\u52a1\uff1asudo systemctl disable &#8211;now \u670d\u52a1\u540d<\/li>\n<li>\u76d1\u63a7\u65e5\u5fd7\uff1agrep Failed \/var\/log\/auth.log<\/li>\n<\/ul>\n<h4 dir=\"auto\">6. \u76d1\u63a7\u4e0e\u544a\u8b66\u57fa\u7840<\/h4>\n<ul dir=\"auto\">\n<li>\u5b89\u88c5 prometheus-node-exporter + grafana\uff08\u6216 netdata \u4e00\u952e\uff09<\/li>\n<li>\u7b80\u5355\u811a\u672c\u76d1\u63a7\uff1auptime\u3001load\u3001disk\u3001\u5185\u5b58\uff0c\u901a\u8fc7\u90ae\u4ef6 \/ webhook \u544a\u8b66<\/li>\n<\/ul>\n<h4 dir=\"auto\">7. \u5bb9\u5668\u4e0e\u865a\u62df\u5316<\/h4>\n<ul dir=\"auto\">\n<li><strong>LXD\/Incus<\/strong>\uff1a\u7cfb\u7edf\u5bb9\u5668\uff0c\u8f7b\u91cf\u865a\u62df\u673a<\/li>\n<li><strong>Docker<\/strong> \u6216 <strong>Podman<\/strong>\uff1a\u5e94\u7528\u5bb9\u5668<\/li>\n<li><strong>MicroK8s<\/strong>\uff1a\u5355\u8282\u70b9 Kubernetes\uff0c\u751f\u4ea7\u53ef\u6269\u5c55<\/li>\n<\/ul>\n<h3 dir=\"auto\">\u56db\u3001\u751f\u4ea7\u73af\u5883\u5e38\u89c1\u8fd0\u7ef4 checklist\uff08\u6bcf\u65e5\/\u6bcf\u5468\/\u6bcf\u6708\uff09<\/h3>\n<p dir=\"auto\"><strong>\u6bcf\u65e5<\/strong>\uff1a<\/p>\n<ul dir=\"auto\">\n<li>\u68c0\u67e5\u8d1f\u8f7d\u3001\u78c1\u76d8\u3001\u5185\u5b58\uff08uptime, free -h, df -h\uff09<\/li>\n<li>tail -f \u5173\u952e\u65e5\u5fd7<\/li>\n<li>\u5b89\u5168\u65e5\u5fd7\u626b\u63cf\uff08auth.log failed\uff09<\/li>\n<\/ul>\n<p dir=\"auto\"><strong>\u6bcf\u5468<\/strong>\uff1a<\/p>\n<ul dir=\"auto\">\n<li>\u5b8c\u6574\u5347\u7ea7 + \u91cd\u542f\u7a97\u53e3\u6d4b\u8bd5<\/li>\n<li>\u5907\u4efd\u9a8c\u8bc1<\/li>\n<li>\u7528\u6237\/\u5bc6\u94a5\u5ba1\u67e5<\/li>\n<\/ul>\n<p dir=\"auto\"><strong>\u6bcf\u6708<\/strong>\uff1a<\/p>\n<ul dir=\"auto\">\n<li>\u5185\u6838\/\u5b89\u5168\u8865\u4e01\u8bc4\u4f30<\/li>\n<li>\u9632\u706b\u5899\u89c4\u5219\u5ba1\u8ba1<\/li>\n<li>\u6027\u80fd\u57fa\u7ebf\u5bf9\u6bd4\uff08sar\uff09<\/li>\n<\/ul>\n<h3 dir=\"auto\">\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u4e0e\u8fdb\u9636\u5efa\u8bae<\/h3>\n<ul dir=\"auto\">\n<li><strong>\u5347\u7ea7\u7b56\u7565<\/strong>\uff1a\u4ece\u4e00\u4e2a LTS \u76f4\u63a5\u8df3\u5230\u4e0b\u4e00\u4e2a LTS\uff08do-release-upgrade\uff09\uff0c\u907f\u514d\u4e2d\u95f4 interim \u7248\u672c\u3002<\/li>\n<li><strong>\u4e91\u4e0a\u4f18\u5316<\/strong>\uff1a\u4f7f\u7528 cloud-init\u3001\u81ea\u52a8\u6269\u7f29\u3001immutable \u955c\u50cf\u3002<\/li>\n<li><strong>\u81ea\u52a8\u5316<\/strong>\uff1aAnsible \/ Terraform \u7ba1\u7406\u591a\u53f0\uff0cGitOps \u65b9\u5f0f\u3002<\/li>\n<li><strong>\u6587\u6863<\/strong>\uff1aCanonical \u5b98\u65b9 Server \u6587\u6863\uff08ubuntu.com\/server\/docs\uff09\u6700\u6743\u5a01\u3002<\/li>\n<\/ul>\n<p dir=\"auto\">Ubuntu Server \u7684\u6838\u5fc3\u4f18\u52bf\u5728\u4e8e\u201c\u591f\u7a33\u5b9a\u3001\u751f\u6001\u5168\u3001\u793e\u533a\u6d3b\u8dc3\u3001\u652f\u6301\u957f\u201d\u3002\u638c\u63e1\u597d\u521d\u59cb\u52a0\u56fa + \u65e5\u5e38\u5de1\u68c0 + \u66f4\u65b0\u8282\u594f\uff0c\u5c31\u80fd\u652f\u6491\u5927\u591a\u6570\u4e2d\u5c0f\u578b\u751f\u4ea7\u8d1f\u8f7d\u3002<\/p>\n<p dir=\"auto\">\u5728 2026 \u5e74\uff0c\u7ed3\u5408 Ubuntu Pro + Livepatch + \u5bb9\u5668\u5316\uff0c\u5355\u53f0\u670d\u52a1\u5668\u7684\u8fd0\u7ef4\u8d1f\u62c5\u5df2\u5927\u5e45\u964d\u4f4e\uff0c\u91cd\u70b9\u8f6c\u5411\u4e1a\u52a1\u67b6\u6784\u800c\u975e\u5e95\u5c42\u7410\u4e8b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu Server \u662f\u5f53&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-210662","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/210662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=210662"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/210662\/revisions"}],"predecessor-version":[{"id":210663,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/210662\/revisions\/210663"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=210662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=210662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=210662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}