Disclosure: this page contains affiliate links. If you buy through them we may earn a commission at no extra cost to you.

SSH(Secure Shell,安全外壳协议)是你登录 VPS 命令行的方式。它是每个 VPS 用户都必须掌握的第一项技能。以下就是全部内容,讲得通俗易懂。

1. 获取你的登录凭据

下单购买 VPS 后,商家会给你一个 IP 地址、一个 用户名(通常是 root)和一个 密码(或者你在设置过程中配置了 SSH 密钥)。

2. 连接

  • macOS / Linux: 打开终端,运行 ssh root@YOUR_IP
  • Windows: 使用 PowerShell(系统自带)或 PuTTY

第一次连接时会要求你输入密码。输入它(屏幕上什么都不会显示——这是正常的),然后按回车。

3. 立刻做这三步安全设置

一台公网 VPS 上线后几分钟内就会被扫描弱 SSH 密码。先做这些:

添加一个非 root 用户:

adduser deploy
usermod -aG sudo deploy

设置 SSH 密钥认证(在你本地电脑上执行):

ssh-copy-id deploy@YOUR_IP

在 /etc/ssh/sshd_config 中 禁用密码登录:

PasswordAuthentication no
PermitRootLogin no

然后运行 sudo systemctl restart ssh。

从哪台 VPS 开始

如果这是你的第一台 VPS,Hostinger 的面板能让初次连接毫无痛苦。如果你想用最便宜的沙盒来练习,RackNerd 的 $21.99/年套餐堪称完美——而且你能拿到一台真正 KVM 机器的 root 权限。

从一台好上手的 VPS 开始:Hostinger 或者入手 RackNerd 的 $22/年沙盒