{"id":655686,"date":"2025-11-18T20:56:55","date_gmt":"2025-11-18T12:56:55","guid":{"rendered":"http:\/\/puo.cn\/?p=655686"},"modified":"2025-11-18T21:02:18","modified_gmt":"2025-11-18T13:02:18","slug":"vps%e5%88%b0%e6%89%8b%e5%90%8e%e8%a6%81%e5%81%9a%e7%9a%84-n-%e9%a1%b9%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"http:\/\/puo.cn\/?p=655686","title":{"rendered":"VPS\u5230\u624b\u540e\u8981\u505a\u7684 N \u9879\u4f18\u5316"},"content":{"rendered":"<h2 id=\"%E5%89%8D%E8%A8%80\"><strong>\u524d\u8a00<\/strong><\/h2>\n<p>\u521a\u62ff\u5230\u4e00\u53f0\u5fc3\u4eeaVPS\u670d\u52a1\u5668\uff0c\u662f\u4e0d\u662f\u5174\u594b\uff1f\u5174\u594b\u8fc7\u540e\uff0c\u6211\u603b\u7ed3\u4e86\u4e00\u4e9b\u4f18\u5316\u9879\u76ee\uff0c\u6309\u7167\u8fd9\u4e2a\u6d41\u7a0b\u64cd\u4f5c\uff0c\u4f60\u7684\u670d\u52a1\u5668\u5c31\u80fd\u4ece&#8221;\u88f8\u673a&#8221;\u53d8\u6210\u6027\u80fd\u5f3a\u52b2\u3001\u5b89\u5168\u53ef\u9760\u3002<\/p>\n<h2 id=\"%E5%BC%80%E5%A7%8B%E4%BC%98%E5%8C%96%E4%B9%8B%E6%97%85\"><strong>\u5f00\u59cb\u4f18\u5316\u4e4b\u65c5<\/strong><\/h2>\n<h3 id=\"1%EF%B8%8F%E2%83%A3-%E6%8D%A2%E6%BA%90%E5%8A%A0%E9%80%9F\"><strong>1\ufe0f\u20e3 \u6362\u6e90\u52a0\u901f<\/strong><\/h3>\n<h4 id=\"%E6%93%8D%E4%BD%9C%E6%AD%A5%E9%AA%A4\"><strong>\u64cd\u4f5c\u6b65\u9aa4<\/strong><\/h4>\n<p>\u9996\u5148\u5907\u4efd\u4e00\u4e0b\u539f\u59cb\u914d\u7f6e\uff0c\u8fd9\u662f\u597d\u4e60\u60ef\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u5907\u4efd\u539f\u59cb\u6e90\u914d\u7f6e\uff08\u4e07\u4e00\u51fa\u95ee\u9898\u8fd8\u80fd\u6062\u590d\uff09<\/span>\r\n<span class=\"line\">cp \/etc\/apt\/sources.list \/etc\/apt\/sources.list.backup<\/span>\r\n\r\n<span class=\"line\"># \u5b89\u88c5HTTPS\u8bc1\u4e66\u652f\u6301<\/span>\r\n<span class=\"line\">apt-get install -y ca-certificates<\/span>\r\n\r\n<span class=\"line\"># \u83b7\u53d6\u7cfb\u7edf\u7248\u672c\u4ee3\u53f7<\/span>\r\n<span class=\"line\">CODENAME=$(lsb_release -cs)<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>\u6211\u63a8\u8350\u51e0\u4e2a\u7a33\u5b9a\u7684\u6e90\uff0c\u6309\u4f60\u7684\u7f51\u7edc\u73af\u5883\u9009\u62e9\uff1a<\/p>\n<p><strong>\u56fd\u5185\u6e90\uff08\u63a8\u8350\u56fd\u5185\u7528\u6237\uff09<\/strong>\uff1a<\/p>\n<ul>\n<li><strong>\u963f\u91cc\u4e91\u6e90<\/strong>\uff1a\u901f\u5ea6\u5feb\uff0c\u7a33\u5b9a\u6027\u597d\uff0c\u63a8\u8350<\/li>\n<li><strong>\u4e2d\u79d1\u5927\u6e90<\/strong>\uff1a\u6559\u80b2\u7f51\u7528\u6237\u9996\u9009<\/li>\n<li><strong>\u6e05\u534e\u6e90<\/strong>\uff1a\u8001\u724c\u7a33\u5b9a\u6e90<\/li>\n<\/ul>\n<p><strong>\u56fd\u5916\u6e90\uff08\u63a8\u8350\u6d77\u5916\u7528\u6237\uff09<\/strong>\uff1a<\/p>\n<ul>\n<li><strong>\u5b98\u65b9\u6e90<\/strong>\uff1a\u6700\u7a33\u5b9a\uff0c\u4f46\u901f\u5ea6\u53ef\u80fd\u8f83\u6162<\/li>\n<li><strong>\u9999\u6e2f\u6e90<\/strong>\uff1a\u4e9a\u6d32\u5730\u533a\u8bbf\u95ee\u8f83\u5feb<\/li>\n<li><strong>\u65e5\u672c\u6e90<\/strong>\uff1a\u4e1c\u4e9a\u5730\u533a\u8bbf\u95ee\u8f83\u5feb<\/li>\n<\/ul>\n<h4 id=\"%E9%85%8D%E7%BD%AE%E5%9B%BD%E5%86%85%E6%BA%90%EF%BC%88%E6%8E%A8%E8%8D%90%E5%9B%BD%E5%86%85%E7%94%A8%E6%88%B7%EF%BC%89\"><strong>\u914d\u7f6e\u56fd\u5185\u6e90\uff08\u63a8\u8350\u56fd\u5185\u7528\u6237\uff09<\/strong><\/h4>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\">cat &gt; \/etc\/apt\/sources.list &lt;&lt;EOF<\/span>\r\n<span class=\"line\">deb http:\/\/mirrors.aliyun.com\/debian\/ ${CODENAME} main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb-src http:\/\/mirrors.aliyun.com\/debian\/ ${CODENAME} main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb http:\/\/mirrors.aliyun.com\/debian-security ${CODENAME}-security main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb-src http:\/\/mirrors.aliyun.com\/debian-security ${CODENAME}-security main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb http:\/\/mirrors.aliyun.com\/debian\/ ${CODENAME}-updates main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb-src http:\/\/mirrors.aliyun.com\/debian\/ ${CODENAME}-updates main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h4 id=\"%E9%85%8D%E7%BD%AE%E5%9B%BD%E5%A4%96%E6%BA%90%EF%BC%88%E6%8E%A8%E8%8D%90%E6%B5%B7%E5%A4%96%E7%94%A8%E6%88%B7%EF%BC%89\"><strong>\u914d\u7f6e\u56fd\u5916\u6e90\uff08\u63a8\u8350\u6d77\u5916\u7528\u6237\uff09<\/strong><\/h4>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\">cat &gt; \/etc\/apt\/sources.list &lt;&lt;EOF<\/span>\r\n<span class=\"line\">deb https:\/\/deb.debian.org\/debian\/ ${CODENAME} main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb-src https:\/\/deb.debian.org\/debian\/ ${CODENAME} main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb https:\/\/deb.debian.org\/debian-security ${CODENAME}-security main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb-src https:\/\/deb.debian.org\/debian-security ${CODENAME}-security main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb https:\/\/deb.debian.org\/debian\/ ${CODENAME}-updates main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">deb-src https:\/\/deb.debian.org\/debian\/ ${CODENAME}-updates main contrib non-free non-free-firmware<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u66f4\u65b0\u4e00\u4e0b\u8f6f\u4ef6\u5305\u5217\u8868\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\">apt update<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>\u5982\u679c\u770b\u5230&#8221;Get:1&#8243;\u8fd9\u6837\u7684\u8f93\u51fa\uff0c\u8bf4\u660e\u6362\u6e90\u6210\u529f\u4e86\uff01\u901f\u5ea6\u5e94\u8be5\u6bd4\u4e4b\u524d\u5feb\u5f88\u591a\u3002<\/p>\n<h3 id=\"2%EF%B8%8F%E2%83%A3-%E8%B4%A6%E6%88%B7%E5%AE%89%E5%85%A8\"><strong>2\ufe0f\u20e3 \u8d26\u6237\u5b89\u5168<\/strong><\/h3>\n<h4 id=\"%E8%AE%BE%E7%BD%AE%E5%BC%BA%E5%AF%86%E7%A0%81\"><strong>\u8bbe\u7f6e\u5f3a\u5bc6\u7801<\/strong><\/h4>\n<p>\u9996\u5148\u7ed9root\u8bbe\u7f6e\u4e00\u4e2a\u5f3a\u5bc6\u7801\uff0c\u522b\u7528123456\u8fd9\u79cd\u5f31\u5bc6\u7801\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u8bbe\u7f6eroot\u5bc6\u7801\uff08\u8bf7\u66ff\u6362\u4e3a\u4f60\u7684\u5f3a\u5bc6\u7801\uff09<\/span>\r\n<span class=\"line\">echo \"root:YourStrongPassword123!\" | chpasswd<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u5bc6\u7801\u8981\u6c42<\/strong>\uff1a\u81f3\u5c118\u4f4d\uff0c\u5305\u542b\u5927\u5c0f\u5199\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u7279\u6b8a\u5b57\u7b26\u3002<\/p>\n<h4 id=\"%E5%88%9B%E5%BB%BA%E6%99%AE%E9%80%9A%E7%94%A8%E6%88%B7\"><strong>\u521b\u5efa\u666e\u901a\u7528\u6237<\/strong><\/h4>\n<p>\u76f4\u63a5\u7528root\u64cd\u4f5c\u662f\u5f88\u5371\u9669\u7684\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u666e\u901a\u7528\u6237\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u521b\u5efa\u7528\u6237\uff08\u66ff\u6362username\u4e3a\u4f60\u7684\u7528\u6237\u540d\uff09<\/span>\r\n<span class=\"line\">useradd -m -s \/bin\/bash username<\/span>\r\n\r\n<span class=\"line\"># \u8bbe\u7f6e\u7528\u6237\u5bc6\u7801<\/span>\r\n<span class=\"line\">echo \"username:UserPassword123!\" | chpasswd<\/span>\r\n\r\n<span class=\"line\"># \u7ed9\u7528\u6237sudo\u6743\u9650<\/span>\r\n<span class=\"line\">usermod -aG sudo username<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>\u8fd9\u6837\u4ee5\u540e\u5c31\u53ef\u4ee5\u7528\u666e\u901a\u7528\u6237\u767b\u5f55\uff0c\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u65f6\u7528sudo\u3002<\/p>\n<h4 id=\"%E9%85%8D%E7%BD%AEssh%E5%AF%86%E9%92%A5%E8%AE%A4%E8%AF%81\"><strong>\u914d\u7f6eSSH\u5bc6\u94a5\u8ba4\u8bc1<\/strong><\/h4>\n<p>\u5bc6\u7801\u767b\u5f55\u867d\u7136\u65b9\u4fbf\uff0c\u4f46SSH\u5bc6\u94a5\u66f4\u5b89\u5168\u3002\u5982\u679c\u4f60\u6709SSH\u5bc6\u94a5\uff0c\u53ef\u4ee5\u8fd9\u6837\u914d\u7f6e\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u521b\u5efaSSH\u76ee\u5f55<\/span>\r\n<span class=\"line\">mkdir -p \/root\/.ssh<\/span>\r\n<span class=\"line\">chmod 700 \/root\/.ssh<\/span>\r\n\r\n<span class=\"line\"># \u6dfb\u52a0\u4f60\u7684\u516c\u94a5\uff08\u8bf7\u66ff\u6362\u4e3a\u4f60\u7684\u5b9e\u9645\u516c\u94a5\uff09<\/span>\r\n<span class=\"line\">echo \"\u4f60\u7684SSH\u516c\u94a5\u5185\u5bb9\" &gt; \/root\/.ssh\/authorized_keys<\/span>\r\n\r\n<span class=\"line\"># \u8bbe\u7f6e\u6b63\u786e\u7684\u6743\u9650<\/span>\r\n<span class=\"line\">chmod 600 \/root\/.ssh\/authorized_keys<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h4 id=\"%E9%85%8D%E7%BD%AEssh%E5%AF%86%E9%92%A5%E8%AE%A4%E8%AF%81%E5%90%8E%E7%9A%84sshd_config%E4%BF%AE%E6%94%B9\"><strong>\u914d\u7f6eSSH\u5bc6\u94a5\u8ba4\u8bc1\u540e\u7684sshd_config\u4fee\u6539<\/strong><\/h4>\n<p>\u914d\u7f6e\u5b8cSSH\u5bc6\u94a5\u540e\uff0c\u9700\u8981\u4fee\u6539SSH\u914d\u7f6e\u4ee5\u542f\u7528\u5bc6\u94a5\u8ba4\u8bc1\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u4fee\u6539SSH\u914d\u7f6e\u4ee5\u652f\u6301\u5bc6\u94a5\u8ba4\u8bc1<\/span>\r\n<span class=\"line\">sed -i 's\/^#*PubkeyAuthentication.*\/PubkeyAuthentication yes\/' \/etc\/ssh\/sshd_config<\/span>\r\n<span class=\"line\">sed -i 's\/^#*PasswordAuthentication.*\/PasswordAuthentication yes\/' \/etc\/ssh\/sshd_config<\/span>\r\n<span class=\"line\">sed -i 's\/^#*PermitRootLogin.*\/PermitRootLogin prohibit-password\/' \/etc\/ssh\/sshd_config<\/span>\r\n\r\n<span class=\"line\"># \u786e\u4fdd\u914d\u7f6e\u751f\u6548<\/span>\r\n<span class=\"line\">systemctl restart ssh<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h3 id=\"3%EF%B8%8F%E2%83%A3-ssh%E5%AE%89%E5%85%A8%E5%8A%A0%E5%9B%BA--\"><strong>3\ufe0f\u20e3 SSH\u5b89\u5168\u52a0\u56fa &#8211;<\/strong><\/h3>\n<p>SSH\u662f\u670d\u52a1\u5668\u7684\u5165\u53e3\uff0c\u5fc5\u987b\u52a0\u5f3a\u9632\u62a4\uff01<\/p>\n<h4 id=\"%E4%BF%AE%E6%94%B9ssh%E7%AB%AF%E5%8F%A3\"><strong>\u4fee\u6539SSH\u7aef\u53e3<\/strong><\/h4>\n<p>\u9ed8\u8ba4\u768422\u7aef\u53e3\u5c31\u50cf\u5728\u95e8\u4e0a\u8d34\u4e86&#8221;\u8bf7\u8fdb&#8221;\u7684\u724c\u5b50\uff0c\u6211\u4eec\u6362\u4e2a\u7aef\u53e3\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u5907\u4efdSSH\u914d\u7f6e\uff08\u597d\u4e60\u60ef\uff09<\/span>\r\n<span class=\"line\">cp \/etc\/ssh\/sshd_config \/etc\/ssh\/sshd_config.backup<\/span>\r\n\r\n<span class=\"line\"># \u4fee\u6539SSH\u7aef\u53e3\u4e3a54321\uff08\u4f60\u53ef\u4ee5\u9009\u62e9\u5176\u4ed6\u7aef\u53e3\uff09<\/span>\r\n<span class=\"line\">sed -i 's\/^#*Port .*\/Port 54321\/' \/etc\/ssh\/sshd_config<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h4 id=\"%E5%BC%BA%E5%8C%96ssh%E5%AE%89%E5%85%A8%E8%AE%BE%E7%BD%AE\"><strong>\u5f3a\u5316SSH\u5b89\u5168\u8bbe\u7f6e<\/strong><\/h4>\n<p>\u73b0\u5728\u7ed9SSH\u52a0\u51e0\u9053\u9501\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u914d\u7f6eSSH\u5b89\u5168\u53c2\u6570<\/span>\r\n<span class=\"line\">cat &gt;&gt; \/etc\/ssh\/sshd_config &lt;&lt;EOF<\/span>\r\n\r\n<span class=\"line\"># \u5b89\u5168\u914d\u7f6e<\/span>\r\n<span class=\"line\">PasswordAuthentication yes<\/span>\r\n<span class=\"line\">ChallengeResponseAuthentication no<\/span>\r\n<span class=\"line\">PermitRootLogin prohibit-password<\/span>\r\n<span class=\"line\">PubkeyAuthentication yes<\/span>\r\n\r\n<span class=\"line\"># \u767b\u5f55\u9650\u901f\uff08\u9632\u6b62\u66b4\u529b\u7834\u89e3\uff09<\/span>\r\n<span class=\"line\">LoginGraceTime 30<\/span>\r\n<span class=\"line\">MaxAuthTries 3<\/span>\r\n\r\n<span class=\"line\"># \u5b89\u5168\u6a2a\u5e45<\/span>\r\n<span class=\"line\">Banner \/etc\/issue.net<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n\r\n<span class=\"line\"># \u521b\u5efa\u5b89\u5168\u6a2a\u5e45\uff08\u5413\u552c\u4e00\u4e0b\u4e0d\u6000\u597d\u610f\u7684\u4eba\uff09<\/span>\r\n<span class=\"line\">echo \"Unauthorized access to this server is prohibited.\" &gt; \/etc\/issue.net<\/span>\r\n\r\n<span class=\"line\"># \u91cd\u542fSSH\u670d\u52a1<\/span>\r\n<span class=\"line\">systemctl restart ssh<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u4fee\u6539SSH\u7aef\u53e3\u540e\uff0c\u8bb0\u5f97\u7528\u65b0\u7aef\u53e3\u8fde\u63a5\uff1a<code>ssh -p 54321 root@your-server-ip<\/code><\/p>\n<h3 id=\"4%EF%B8%8F%E2%83%A3-%E9%98%B2%E7%81%AB%E5%A2%99%E9%85%8D%E7%BD%AE\"><strong>4\ufe0f\u20e3 \u9632\u706b\u5899\u914d\u7f6e<\/strong><\/h3>\n<h4 id=\"%E5%AE%89%E8%A3%85nftables\"><strong>\u5b89\u88c5nftables<\/strong><\/h4>\n<p>\u9ed8\u8ba4\u7684ufw\u9632\u706b\u5899\u529f\u80fd\u6709\u9650\uff0c\u6211\u4eec\u6362\u6210\u66f4\u5f3a\u5927\u7684nftables\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u5378\u8f7dufw\uff08\u5982\u679c\u5b58\u5728\uff09<\/span>\r\n<span class=\"line\">if command -v ufw &gt;\/dev\/null 2&gt;&amp;1; then<\/span>\r\n<span class=\"line\">    ufw --force reset<\/span>\r\n<span class=\"line\">    ufw disable<\/span>\r\n<span class=\"line\">    apt-get purge -y ufw<\/span>\r\n<span class=\"line\">fi<\/span>\r\n\r\n<span class=\"line\"># \u5b89\u88c5nftables<\/span>\r\n<span class=\"line\">apt-get install -y nftables<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h4 id=\"%E9%85%8D%E7%BD%AE%E5%9F%BA%E7%A1%80%E9%98%B2%E7%81%AB%E5%A2%99%E8%A7%84%E5%88%99\"><strong>\u914d\u7f6e\u57fa\u7840\u9632\u706b\u5899\u89c4\u5219<\/strong><\/h4>\n<p>\u73b0\u5728\u914d\u7f6e\u9632\u706b\u5899\u89c4\u5219\uff0c\u53ea\u5141\u8bb8\u5fc5\u8981\u7684\u6d41\u91cf\u901a\u8fc7\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u521b\u5efanftables\u914d\u7f6e\u6587\u4ef6<\/span>\r\n<span class=\"line\">cat &gt; \/etc\/nftables.conf &lt;&lt;EOF<\/span>\r\n<span class=\"line\">#!\/usr\/sbin\/nft -f<\/span>\r\n\r\n<span class=\"line\">flush ruleset<\/span>\r\n\r\n<span class=\"line\">table inet filter {<\/span>\r\n<span class=\"line\">    chain input {<\/span>\r\n<span class=\"line\">        type filter hook input priority 0;<\/span>\r\n<span class=\"line\">        policy drop;<\/span>\r\n\r\n<span class=\"line\">        # \u5141\u8bb8\u672c\u5730\u56de\u73af\uff08\u672c\u673a\u8bbf\u95ee\uff09<\/span>\r\n<span class=\"line\">        iif lo accept<\/span>\r\n\r\n<span class=\"line\">        # \u5141\u8bb8\u5df2\u5efa\u7acb\u7684\u8fde\u63a5\uff08\u56de\u590d\u5305\uff09<\/span>\r\n<span class=\"line\">        ct state established,related accept<\/span>\r\n\r\n<span class=\"line\">        # \u5f00\u653eSSH\u7aef\u53e3\uff08\u8bb0\u5f97\u6539\u6210\u4f60\u7684\u7aef\u53e3\uff09<\/span>\r\n<span class=\"line\">        tcp dport 54321 accept<\/span>\r\n<span class=\"line\">        udp dport 54321 accept<\/span>\r\n<span class=\"line\">    }<\/span>\r\n<span class=\"line\">    chain forward {<\/span>\r\n<span class=\"line\">        type filter hook forward priority 0;<\/span>\r\n<span class=\"line\">        policy drop;<\/span>\r\n<span class=\"line\">    }<\/span>\r\n<span class=\"line\">    chain output {<\/span>\r\n<span class=\"line\">        type filter hook output priority 0;<\/span>\r\n<span class=\"line\">        policy accept;<\/span>\r\n<span class=\"line\">    }<\/span>\r\n<span class=\"line\">}<\/span>\r\n\r\n<span class=\"line\"># \u6d41\u91cf\u76d1\u63a7\u8868\uff08\u7528\u4e8e\u7edf\u8ba1\uff09<\/span>\r\n<span class=\"line\">table inet mangle {<\/span>\r\n<span class=\"line\">    chain prerouting {<\/span>\r\n<span class=\"line\">        type filter hook prerouting priority mangle;<\/span>\r\n<span class=\"line\">        policy accept;<\/span>\r\n<span class=\"line\">    }<\/span>\r\n<span class=\"line\">    chain output {<\/span>\r\n<span class=\"line\">        type route hook output priority mangle;<\/span>\r\n<span class=\"line\">        policy accept;<\/span>\r\n<span class=\"line\">    }<\/span>\r\n<span class=\"line\">    chain input {<\/span>\r\n<span class=\"line\">        type filter hook input priority mangle;<\/span>\r\n<span class=\"line\">        policy accept;<\/span>\r\n<span class=\"line\">    }<\/span>\r\n<span class=\"line\">}<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n\r\n<span class=\"line\"># \u542f\u7528\u5e76\u542f\u52a8nftables<\/span>\r\n<span class=\"line\">systemctl enable nftables<\/span>\r\n<span class=\"line\">systemctl restart nftables<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p>\u9632\u706b\u5899\u914d\u7f6e\u5b8c\u6210\uff01\u73b0\u5728\u53ea\u6709SSH\u7aef\u53e3\u662f\u5f00\u653e\u7684\uff0c\u5176\u4ed6\u7aef\u53e3\u90fd\u88ab\u5c4f\u853d\u4e86\u3002<\/p>\n<h3 id=\"5%EF%B8%8F%E2%83%A3-%E7%B3%BB%E7%BB%9F%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96---%E8%AE%A9%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%B7%91%E5%BE%97%E6%9B%B4%E5%BF%AB\"><strong>5\ufe0f\u20e3 \u7cfb\u7edf\u6027\u80fd\u4f18\u5316 &#8211; \u8ba9\u670d\u52a1\u5668\u8dd1\u5f97\u66f4\u5feb<\/strong><\/h3>\n<h4 id=\"%E7%B3%BB%E7%BB%9F%E5%8F%82%E6%95%B0%E8%B0%83%E4%BC%98\"><strong>\u7cfb\u7edf\u53c2\u6570\u8c03\u4f18<\/strong><\/h4>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u521b\u5efa\u7cfb\u7edf\u53c2\u6570\u914d\u7f6e\u6587\u4ef6<\/span>\r\n<span class=\"line\">cat &gt; \/etc\/sysctl.d\/99-custom.conf &lt;&lt;EOF<\/span>\r\n<span class=\"line\"># \u7f51\u7edc\u6027\u80fd\u4f18\u5316<\/span>\r\n<span class=\"line\">net.ipv4.tcp_congestion_control = bbr<\/span>\r\n<span class=\"line\">net.core.default_qdisc = fq<\/span>\r\n<span class=\"line\">net.core.rmem_max = 33554432<\/span>\r\n<span class=\"line\">net.core.wmem_max = 33554432<\/span>\r\n<span class=\"line\">net.core.somaxconn = 4096<\/span>\r\n<span class=\"line\">net.ipv4.tcp_max_syn_backlog = 4096<\/span>\r\n<span class=\"line\">net.ipv4.tcp_rmem = 4096 1048576 33554432<\/span>\r\n<span class=\"line\">net.ipv4.tcp_wmem = 4096 1048576 33554432<\/span>\r\n<span class=\"line\">net.ipv4.tcp_window_scaling = 1<\/span>\r\n<span class=\"line\">net.ipv4.tcp_adv_win_scale = 1<\/span>\r\n<span class=\"line\">net.ipv4.tcp_fastopen = 3<\/span>\r\n<span class=\"line\">net.ipv4.ip_forward = 1<\/span>\r\n<span class=\"line\">net.ipv6.conf.all.forwarding = 1<\/span>\r\n<span class=\"line\">net.ipv4.tcp_timestamps = 1<\/span>\r\n<span class=\"line\">net.ipv4.tcp_sack = 1<\/span>\r\n<span class=\"line\">kernel.panic = 1<\/span>\r\n<span class=\"line\">vm.swappiness = 3<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n\r\n<span class=\"line\"># \u5e94\u7528\u7cfb\u7edf\u53c2\u6570<\/span>\r\n<span class=\"line\">sysctl --system<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h4 id=\"%E8%99%9A%E6%8B%9F%E5%86%85%E5%AD%98%E9%85%8D%E7%BD%AE\"><strong>\u865a\u62df\u5185\u5b58\u914d\u7f6e<\/strong><\/h4>\n<p>\u5c0f\u5185\u5b58\u670d\u52a1\u5668\u5fc5\u5907\uff01\u5f53\u7269\u7406\u5185\u5b58\u4e0d\u591f\u65f6\uff0c\u7cfb\u7edf\u4f1a\u4f7f\u7528\u865a\u62df\u5185\u5b58\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u521b\u5efaswap\u6587\u4ef6\uff08\u6839\u636e\u670d\u52a1\u5668\u5185\u5b58\u5927\u5c0f\u8c03\u6574\uff09<\/span>\r\n<span class=\"line\">SWAP_SIZE=2G  # \u5efa\u8bae\u4e3a\u7269\u7406\u5185\u5b58\u76841-2\u500d<\/span>\r\n\r\n<span class=\"line\"># \u521b\u5efaswap\u6587\u4ef6<\/span>\r\n<span class=\"line\">fallocate -l $SWAP_SIZE \/swapfile<\/span>\r\n\r\n<span class=\"line\"># \u8bbe\u7f6e\u6743\u9650<\/span>\r\n<span class=\"line\">chmod 600 \/swapfile<\/span>\r\n\r\n<span class=\"line\"># \u683c\u5f0f\u5316swap\u6587\u4ef6<\/span>\r\n<span class=\"line\">mkswap \/swapfile<\/span>\r\n\r\n<span class=\"line\"># \u542f\u7528swap<\/span>\r\n<span class=\"line\">swapon \/swapfile<\/span>\r\n\r\n<span class=\"line\"># \u6dfb\u52a0\u5230fstab\u5b9e\u73b0\u5f00\u673a\u81ea\u52a8\u6302\u8f7d<\/span>\r\n<span class=\"line\">echo \"\/swapfile none swap sw 0 0\" &gt;&gt; \/etc\/fstab<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u5c0f\u8d34\u58eb<\/strong>\uff1a\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668\u5185\u5b58\u5927\u4e8e4GB\uff0c\u53ef\u4ee5\u4e0d\u7528\u914d\u7f6eswap\uff0c\u6216\u8005\u914d\u7f6e1GB\u5c31\u591f\u4e86\u3002<\/p>\n<h3 id=\"6%EF%B8%8F%E2%83%A3-%E6%97%B6%E9%97%B4%E5%90%8C%E6%AD%A5---%E8%AE%A9%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%97%B6%E9%97%B4%E5%87%86%E7%A1%AE\"><strong>6\ufe0f\u20e3 \u65f6\u95f4\u540c\u6b65 &#8211; \u8ba9\u670d\u52a1\u5668\u65f6\u95f4\u51c6\u786e<\/strong><\/h3>\n<p>\u670d\u52a1\u5668\u65f6\u95f4\u4e0d\u51c6\u786e\u4f1a\u5bfc\u81f4\u5f88\u591a\u95ee\u9898\uff0c\u6bd4\u5982\u65e5\u5fd7\u65f6\u95f4\u9519\u4e71\u3001\u8bc1\u4e66\u9a8c\u8bc1\u5931\u8d25\u7b49\u3002<\/p>\n<h4 id=\"%E8%AE%BE%E7%BD%AE%E6%97%B6%E5%8C%BA\"><strong>\u8bbe\u7f6e\u65f6\u533a<\/strong><\/h4>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u8bbe\u7f6e\u4e3a\u4e0a\u6d77\u65f6\u533a\uff08\u56fd\u5185\u7528\u6237\uff09<\/span>\r\n<span class=\"line\">timedatectl set-timezone Asia\/Shanghai<\/span>\r\n\r\n<span class=\"line\"># \u9a8c\u8bc1\u65f6\u533a\u8bbe\u7f6e<\/span>\r\n<span class=\"line\">timedatectl<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h4 id=\"%E9%85%8D%E7%BD%AEntp%E6%97%B6%E9%97%B4%E5%90%8C%E6%AD%A5\"><strong>\u914d\u7f6eNTP\u65f6\u95f4\u540c\u6b65<\/strong><\/h4>\n<p><strong>\u56fd\u5185\u7528\u6237\u63a8\u8350<\/strong>\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u5b89\u88c5\u65f6\u95f4\u540c\u6b65\u670d\u52a1<\/span>\r\n<span class=\"line\">apt-get install -y systemd-timesyncd<\/span>\r\n\r\n<span class=\"line\"># \u914d\u7f6e\u56fd\u5185NTP\u670d\u52a1\u5668<\/span>\r\n<span class=\"line\">cat &gt; \/etc\/systemd\/timesyncd.conf &lt;&lt;EOF<\/span>\r\n<span class=\"line\">[Time]<\/span>\r\n<span class=\"line\">NTP=ntp.aliyun.com ntp.ntsc.ac.cn time1.cloud.tencent.com cn.pool.ntp.org<\/span>\r\n<span class=\"line\">FallbackNTP=ntp1.aliyun.com ntp2.aliyun.com time2.cloud.tencent.com<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u6d77\u5916\u7528\u6237\u63a8\u8350<\/strong>\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u914d\u7f6e\u56fd\u9645NTP\u670d\u52a1\u5668<\/span>\r\n<span class=\"line\">cat &gt; \/etc\/systemd\/timesyncd.conf &lt;&lt;EOF<\/span>\r\n<span class=\"line\">[Time]<\/span>\r\n<span class=\"line\">NTP=pool.ntp.org time1.google.com time.apple.com time.cloudflare.com time.windows.com<\/span>\r\n<span class=\"line\">FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u542f\u7528\u65f6\u95f4\u540c\u6b65<\/strong>\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u542f\u7528\u5e76\u542f\u52a8\u65f6\u95f4\u540c\u6b65\u670d\u52a1<\/span>\r\n<span class=\"line\">systemctl unmask systemd-timesyncd.service<\/span>\r\n<span class=\"line\">systemctl enable systemd-timesyncd.service<\/span>\r\n<span class=\"line\">systemctl restart systemd-timesyncd.service<\/span>\r\n<span class=\"line\">timedatectl set-ntp yes<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h3 id=\"7%EF%B8%8F%E2%83%A3-%E5%AE%89%E5%85%A8%E5%8A%A0%E5%9B%BA---%E7%BB%99%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%A9%BF%E4%B8%8A%E9%98%B2%E5%BC%B9%E8%A1%A3\"><strong>7\ufe0f\u20e3 \u5b89\u5168\u52a0\u56fa &#8211; \u7ed9\u670d\u52a1\u5668\u7a7f\u4e0a\u9632\u5f39\u8863<\/strong><\/h3>\n<h4 id=\"%E5%AE%89%E8%A3%85fail2ban%E9%98%B2%E6%9A%B4%E5%8A%9B%E7%A0%B4%E8%A7%A3\"><strong>\u5b89\u88c5Fail2Ban\u9632\u66b4\u529b\u7834\u89e3<\/strong><\/h4>\n<p>Fail2Ban\u5c31\u50cf\u4e00\u4e2a\u667a\u80fd\u95e8\u536b\uff0c\u53d1\u73b0\u6709\u4eba\u5c1d\u8bd5\u66b4\u529b\u7834\u89e3\u5c31\u81ea\u52a8\u5c01IP\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u5b89\u88c5Fail2Ban<\/span>\r\n<span class=\"line\">apt-get install -y fail2ban<\/span>\r\n\r\n<span class=\"line\"># \u914d\u7f6eSSH\u4fdd\u62a4<\/span>\r\n<span class=\"line\">cat &gt; \/etc\/fail2ban\/jail.d\/sshd.local &lt;&lt;EOF<\/span>\r\n<span class=\"line\">[sshd]<\/span>\r\n<span class=\"line\">enabled = true<\/span>\r\n<span class=\"line\">port = 54321<\/span>\r\n<span class=\"line\">filter = sshd<\/span>\r\n<span class=\"line\">logpath = \/var\/log\/auth.log<\/span>\r\n<span class=\"line\">maxretry = 5<\/span>\r\n<span class=\"line\">findtime = 10m<\/span>\r\n<span class=\"line\">bantime = 30m<\/span>\r\n<span class=\"line\">backend = systemd<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n\r\n<span class=\"line\"># \u542f\u52a8Fail2Ban<\/span>\r\n<span class=\"line\">systemctl enable --now fail2ban<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u6548\u679c<\/strong>\uff1a\u5982\u679c\u6709\u4eba5\u6b21\u5bc6\u7801\u9519\u8bef\uff0cIP\u4f1a\u88ab\u5c0130\u5206\u949f\u3002<\/p>\n<h4 id=\"%E9%85%8D%E7%BD%AE%E8%87%AA%E5%8A%A8%E5%AE%89%E5%85%A8%E6%9B%B4%E6%96%B0\"><strong>\u914d\u7f6e\u81ea\u52a8\u5b89\u5168\u66f4\u65b0<\/strong><\/h4>\n<p>\u8ba9\u7cfb\u7edf\u81ea\u52a8\u5b89\u88c5\u5b89\u5168\u8865\u4e01\uff0c\u7701\u5fc3\u53c8\u5b89\u5168\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u5b89\u88c5\u81ea\u52a8\u66f4\u65b0\u5de5\u5177<\/span>\r\n<span class=\"line\">apt-get install -y unattended-upgrades<\/span>\r\n\r\n<span class=\"line\"># \u914d\u7f6e\u81ea\u52a8\u66f4\u65b0<\/span>\r\n<span class=\"line\">dpkg-reconfigure -plow unattended-upgrades<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h4 id=\"icmp-ping%E6%8E%A7%E5%88%B6%EF%BC%88%E5%8F%AF%E9%80%89%EF%BC%89\"><strong>ICMP Ping\u63a7\u5236\uff08\u53ef\u9009\uff09<\/strong><\/h4>\n<p>\u5982\u679c\u4f60\u4e0d\u60f3\u8ba9\u522b\u4ebaping\u4f60\u7684\u670d\u52a1\u5668\uff1a<\/p>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u7981\u7528Ping\uff08\u53ef\u9009\uff09<\/span>\r\n<span class=\"line\">cat &gt; \/etc\/sysctl.d\/99-vpsbox-icmp.conf &lt;&lt;EOF<\/span>\r\n<span class=\"line\">net.ipv4.icmp_echo_ignore_all = 1<\/span>\r\n<span class=\"line\">EOF<\/span>\r\n\r\n<span class=\"line\"># \u5e94\u7528\u8bbe\u7f6e<\/span>\r\n<span class=\"line\">sysctl -w net.ipv4.icmp_echo_ignore_all=1<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u7981\u7528ping\u540e\uff0c\u4f60\u81ea\u5df1\u4e5fping\u4e0d\u4e86\u5916\u7f51\u4e86\uff0c\u4f46\u4e0d\u4f1a\u5f71\u54cd\u6b63\u5e38\u7f51\u7edc\u4f7f\u7528\u3002<\/p>\n<h3 id=\"8%EF%B8%8F%E2%83%A3-%E7%B3%BB%E7%BB%9F%E6%B8%85%E7%90%86\"><strong>8\ufe0f\u20e3 \u7cfb\u7edf\u6e05\u7406<\/strong><\/h3>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u6e05\u7406\u8f6f\u4ef6\u5305\u7f13\u5b58<\/span>\r\n<span class=\"line\">apt-get clean<\/span>\r\n<span class=\"line\">apt-get autoremove -y<\/span>\r\n<span class=\"line\">apt-get autoclean<\/span>\r\n\r\n<span class=\"line\"># \u6e05\u7406\u65e5\u5fd7\u6587\u4ef6<\/span>\r\n<span class=\"line\">find \/var\/log -type f -name \"*.gz\" -delete<\/span>\r\n<span class=\"line\">find \/var\/log -type f -name \"*.old\" -delete<\/span>\r\n<span class=\"line\">find \/var\/log -type f -name \"*.1\" -delete<\/span>\r\n<span class=\"line\">journalctl --vacuum-time=7d<\/span>\r\n\r\n<span class=\"line\"># \u6e05\u7406\u4e34\u65f6\u6587\u4ef6<\/span>\r\n<span class=\"line\">find \/tmp -type f -atime +7 -delete<\/span>\r\n<span class=\"line\">find \/var\/tmp -type f -atime +7 -delete<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h2 id=\"%F0%9F%8E%89-%E9%AA%8C%E8%AF%81%E4%B8%80%E4%B8%8B\"><strong>\ud83c\udf89 \u9a8c\u8bc1\u4e00\u4e0b<\/strong><\/h2>\n<h3 id=\"%E6%A3%80%E6%9F%A5ssh%E8%BF%9E%E6%8E%A5\"><strong>\u68c0\u67e5SSH\u8fde\u63a5<\/strong><\/h3>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u4f7f\u7528\u65b0\u7aef\u53e3\u6d4b\u8bd5SSH\u8fde\u63a5<\/span>\r\n<span class=\"line\">ssh -p 54321 root@your-server-ip<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h3 id=\"%E6%A3%80%E6%9F%A5%E9%98%B2%E7%81%AB%E5%A2%99%E7%8A%B6%E6%80%81\"><strong>\u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001<\/strong><\/h3>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u67e5\u770bnftables\u89c4\u5219<\/span>\r\n<span class=\"line\">nft list ruleset<\/span>\r\n\r\n<span class=\"line\"># \u68c0\u67e5\u9632\u706b\u5899\u670d\u52a1\u72b6\u6001<\/span>\r\n<span class=\"line\">systemctl status nftables<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h3 id=\"%E6%A3%80%E6%9F%A5%E7%B3%BB%E7%BB%9F%E7%8A%B6%E6%80%81\"><strong>\u68c0\u67e5\u7cfb\u7edf\u72b6\u6001<\/strong><\/h3>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u67e5\u770b\u7cfb\u7edf\u8d44\u6e90\u4f7f\u7528<\/span>\r\n<span class=\"line\">free -h<\/span>\r\n<span class=\"line\">df -h<\/span>\r\n<span class=\"line\">uptime<\/span>\r\n\r\n<span class=\"line\"># \u67e5\u770b\u7f51\u7edc\u8fde\u63a5<\/span>\r\n<span class=\"line\">ss -tuln<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h3 id=\"%E6%A3%80%E6%9F%A5%E5%AE%89%E5%85%A8%E9%85%8D%E7%BD%AE\"><strong>\u68c0\u67e5\u5b89\u5168\u914d\u7f6e<\/strong><\/h3>\n<div class=\"shadow rounded-lg relative group\">\n<pre class=\"shiki shiki-themes github-light github-dark\" tabindex=\"0\"><code><span class=\"line\"># \u67e5\u770bFail2Ban\u72b6\u6001<\/span>\r\n<span class=\"line\">fail2ban-client status<\/span>\r\n\r\n<span class=\"line\"># \u67e5\u770bSSH\u914d\u7f6e<\/span>\r\n<span class=\"line\">sshd -T | grep -E \"port|password|permitroot\"<\/span>\r\n<\/code><\/pre>\n<div class=\"absolute select-none top-1 text-xs right-2 group-hover:opacity-0 transition-opacity\">shellscript<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h2 id=\"%E2%9A%A0%EF%B8%8F-%E9%87%8D%E8%A6%81%E6%8F%90%E9%86%92\"><strong>\u26a0\ufe0f \u91cd\u8981\u63d0\u9192<\/strong><\/h2>\n<ol>\n<li><strong>\u5907\u4efd\u914d\u7f6e<\/strong>\uff1a\u4fee\u6539\u524d\u4e00\u5b9a\u8981\u5907\u4efd\uff0c\u8fd9\u662f\u8840\u7684\u6559\u8bad\uff01<\/li>\n<li><strong>\u6d4b\u8bd5\u8fde\u63a5<\/strong>\uff1a\u6539SSH\u7aef\u53e3\u540e\uff0c\u8bb0\u5f97\u7528\u65b0\u7aef\u53e3\u8fde\u63a5<\/li>\n<li><strong>\u9632\u706b\u5899\u89c4\u5219<\/strong>\uff1a\u65b0\u5f00\u670d\u52a1\u7aef\u53e3\u65f6\uff0c\u8bb0\u5f97\u5728\u9632\u706b\u5899\u4e2d\u5f00\u653e<\/li>\n<li><strong>\u5b9a\u671f\u66f4\u65b0<\/strong>\uff1a\u6bcf\u5468\u6267\u884c\u00a0<code>apt update &amp;&amp; apt upgrade<\/code><\/li>\n<li><strong>\u76d1\u63a7\u65e5\u5fd7<\/strong>\uff1a\u5b9a\u671f\u68c0\u67e5\u65e5\u5fd7\uff0c\u53d1\u73b0\u95ee\u9898\u53ca\u65f6\u5904\u7406<\/li>\n<\/ol>\n<h2 id=\"%F0%9F%94%A7-%E6%97%A5%E5%B8%B8%E7%BB%B4%E6%8A%A4%E5%BB%BA%E8%AE%AE\"><strong>\ud83d\udd27 \u65e5\u5e38\u7ef4\u62a4\u5efa\u8bae<\/strong><\/h2>\n<ol>\n<li><strong>\u6bcf\u5468\u66f4\u65b0<\/strong>\uff1a<code>apt update &amp;&amp; apt upgrade<\/code><\/li>\n<li><strong>\u76d1\u63a7\u8d44\u6e90<\/strong>\uff1a\u7528\u00a0<code>htop<\/code>\u3001<code>iotop<\/code>\u00a0\u76d1\u63a7\u7cfb\u7edf\u72b6\u6001<\/li>\n<li><strong>\u6e05\u7406\u65e5\u5fd7<\/strong>\uff1a\u5b9a\u671f\u6e05\u7406\u65e5\u5fd7\u6587\u4ef6\uff0c\u907f\u514d\u78c1\u76d8\u6ee1<\/li>\n<li><strong>\u5b89\u5168\u68c0\u67e5<\/strong>\uff1a\u5b9a\u671f\u68c0\u67e5\u7528\u6237\u6743\u9650\u548cSSH\u5bc6\u94a5<\/li>\n<li><strong>\u5907\u4efd\u6570\u636e<\/strong>\uff1a\u91cd\u8981\u6570\u636e\u4e00\u5b9a\u8981\u5b9a\u671f\u5907\u4efd<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u521a\u62ff\u5230\u4e00\u53f0\u5fc3\u4eeaVPS\u670d\u52a1\u5668\uff0c\u662f\u4e0d\u662f\u5174\u594b\uff1f\u5174\u594b\u8fc7\u540e\uff0c\u6211\u603b\u7ed3\u4e86\u4e00\u4e9b\u4f18\u5316\u9879\u76ee\uff0c\u6309\u7167\u8fd9\u4e2a\u6d41\u7a0b\u64cd\u4f5c\uff0c\u4f60\u7684\u670d\u52a1\u5668\u5c31\u80fd\u4ece&#8221;\u88f8\u673a&#8221;\u53d8\u6210\u6027\u80fd\u5f3a\u52b2\u3001\u5b89\u5168\u53ef\u9760\u3002 \u5f00\u59cb\u4f18\u5316\u4e4b\u65c5 1\ufe0f\u20e3 \u6362\u6e90\u52a0\u901f \u64cd\u4f5c\u6b65\u9aa4 \u9996\u5148\u5907\u4efd\u4e00\u4e0b\u539f\u59cb\u914d\u7f6e\uff0c\u8fd9\u662f\u597d&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128],"tags":[949,950,847],"topic":[],"class_list":["post-655686","post","type-post","status-publish","format-standard","hentry","category-128","tag-apt","tag-etc","tag-vps"],"_links":{"self":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/655686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=655686"}],"version-history":[{"count":2,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/655686\/revisions"}],"predecessor-version":[{"id":655688,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/655686\/revisions\/655688"}],"wp:attachment":[{"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=655686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=655686"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=655686"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=655686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}