{"id":956,"date":"2024-11-13T17:20:30","date_gmt":"2024-11-13T09:20:30","guid":{"rendered":"http:\/\/www.huerpu.cc:7000\/?p=956"},"modified":"2024-11-13T17:29:19","modified_gmt":"2024-11-13T09:29:19","slug":"ubuntu-server-24-04%e4%b8%8a%e6%89%8b%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"http:\/\/www.huerpu.cc:7000\/?p=956","title":{"rendered":"ubuntu-server-24.04\u4e0a\u624b\u6307\u5357"},"content":{"rendered":"<h1>ubuntu-server-24.04\u4e0a\u624b\u6307\u5357<\/h1>\n<h2>\u4e00\u3001\u66f4\u65b0\u5e76\u5b89\u88c5\u57fa\u7840\u8f6f\u4ef6<\/h2>\n<pre><code class=\"language-shell\">#\u5207\u6362root\u7528\u6237\nsudo su -\n\n#\u66f4\u65b0\napt update \n\n#\u5347\u7ea7\napt upgrade\n\n#install vim\napt install vim\n\n#install net-tools\napt install net-tools<\/code><\/pre>\n<h2>\u4e8c\u3001\u5b89\u88c5ssh\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8<\/h2>\n<pre><code class=\"language-shell\">#install ssh\napt install openssh-server\napt install openssh-client\n\n#\u91cd\u542fssh\u670d\u52a1\nservice ssh restart\n\nvim \/root\/.bashrc\n#\u6587\u4ef6\u672b\u5c3e\u589e\u52a0\u4e00\u6761\u8bb0\u5f55service ssh start\nservice ssh start\n\n#\u5c06PermitRootLogin\u7684\u503c\u6539\u4e3ayes\uff0c\/\u641c\u7d22\u5373\u53ef\uff0c\u8d85\u7ea7\u7b80\u5355\nvim \/etc\/ssh\/sshd_config\nPermitRootLogin yes\n\n#\u4fee\u6539root\u5bc6\u7801\npasswd root\n\n#\u653e\u5f0022\u7aef\u53e3\nufw allow 22<\/code><\/pre>\n<h2>\u4e09\u3001\u8bbe\u7f6eubuntu\u66f4\u65b0\u6e90\u4e3a\u963f\u91cc\u6e90<\/h2>\n<pre><code class=\"language-shell\">#\u66f4\u6362\u963f\u91cc\u6e90\uff0c\u5df2\u7ecf\u4e0d\u662f\u539f\u6765\u7684\u8def\u5f84\/etc\/apt\/sources.list\nvim \/etc\/apt\/sources.list.d\/ubuntu.sources\n\n#\/etc\/apt\/sources.list.d\/ubuntu.sources\u5176\u5185\u5bb9\u4e3a\nTypes: deb\nURIs: http:\/\/cn.archive.ubuntu.com\/ubuntu\/\nSuites: noble noble-updates noble-backports\nComponents: main restricted universe multiverse\nSigned-By: \/usr\/share\/keyrings\/ubuntu-archive-keyring.gpg\n\nTypes: deb\nURIs: http:\/\/security.ubuntu.com\/ubuntu\/\nSuites: noble-security\nComponents: main restricted universe multiverse\nSigned-By: \/usr\/share\/keyrings\/ubuntu-archive-keyring.gpg\n\n#\u628a\u5176\u4e2d\u7684http:\/\/cn.archive.ubuntu.com\/ubuntu\/\uff0c\u4fee\u6539\u4e3ahttp:\/\/mirrors.aliyun.com\/ubuntu\/\n\n#\u4fdd\u5b58\u5e76\u9000\u51fa\n\uff1awq\n\n#\u66f4\u65b0\napt update \n\n#\u5347\u7ea7\napt upgrade<\/code><\/pre>\n<h2>\u56db\u3001\u547d\u4ee4\u884c\u8bbe\u7f6e\u9759\u6001IP\u5730\u5740<\/h2>\n<pre><code class=\"language-shell\">#\u8fdb\u5165\u7f51\u7edc\u7ba1\u7406\u76ee\u5f55\ncd \/etc\/netplan\n\nroot@kelsen-ubuntu-desktop:\/etc\/netplan# ls\n50-cloud-init.yaml\n\nvim 50-cloud-init.yaml\n\n# \u8bbe\u7f6e600\u7684\u6587\u4ef6\u6743\u9650\uff0c\u5426\u5219\u4f1a\u62a5\u9519Permissions for \/etc\/netplan\/01-network-manager-all.yaml are too open. Netplan configuration should NOT be accessible by others.\nchmod 600 \/etc\/netplan\/50-cloud-init.yaml\n\n#\u89e3\u51b3\u865a\u62df\u673a\u4e0b\u7f51\u7edc\u62a5\u9519\u7684\u95ee\u9898\napt-get install openvswitch-switch\n\n#50-cloud-init.yaml\u539f\u6765\u7684\u5185\u5bb9\u4e3a\nnetwork:\n    ethernets:\n        ens18:\n            dhcp4: true\n    version: 2\n\n#50-cloud-init.yaml\u4fee\u6539\u4e3a\nnetwork:\n    version: 2\n    renderer: networkd\n    ethernets:\n        ens18:   #ens18\u53ef\u6839\u636e\u547d\u4ee4ifconfig -a \u663e\u793a\u7684\u7f51\u5361\u540d\n            dhcp4: no\n            addresses:\n              - 192.168.31.55\/24\n            routes:\n              - to: default\n                via: 192.168.31.1 # \u5c06\u6b64\u5904\u7684\u7f51\u5173\u5730\u5740\u66ff\u6362\u4e3a\u4f60\u5bb6\u5ead\u8def\u7531\u5668\u7684\u7f51\u5173\u5730\u5740\uff0c\u5bb6\u5ead\u7f51\u7edc\u4e2d\u5c31\u662f\u8def\u7531\u5668\u5730\u5740\n            nameservers:\n              addresses: [192.168.31.1,8.8.8.8,8.8.4.4] #\u53ef\u6839\u636e\u9700\u8981\u4fee\u6539\u4e3a\u4f60\u5e38\u7528\u7684DNS\u670d\u52a1\u5668\u5730\u5740,192.168.31.1\u4e3a\u8def\u7531\u5668\u5730\u5740\u7531\u8def\u7531\u5668\u505a\u4e3aDNS\uff0c8.8.8.8,8.8.4.4\u4e3a\u516c\u7f51DNS\uff0c\u8fd9\u6837\u7cfb\u7edf\u4f1a\u9996\u5148\u5c1d\u8bd5\u4f7f\u7528\u8def\u7531\u5668\u7684 DNS \u670d\u52a1\u5668\u8fdb\u884c\u57df\u540d\u89e3\u6790\uff0c\u5982\u679c\u8def\u7531\u5668\u7684 DNS \u670d\u52a1\u5668\u65e0\u6cd5\u89e3\u6790\uff0c\u5219\u4f1a\u81ea\u52a8\u4f7f\u7528\u7b2c\u4e8c\u4e2a DNS \u670d\u52a1\u5668\u59828.8.8.8\u8fdb\u884c\u89e3\u6790\n\n#\u5e94\u7528\nnetplan apply<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ubuntu-server-24.04\u4e0a\u624b\u6307\u5357 \u4e00\u3001\u66f4\u65b0\u5e76\u5b89\u88c5\u57fa\u7840\u8f6f\u4ef6 #\u5207\u6362root\u7528\u6237 sudo su &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-956","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=956"}],"version-history":[{"count":2,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/956\/revisions"}],"predecessor-version":[{"id":961,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/956\/revisions\/961"}],"wp:attachment":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=956"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}