跳到主要内容

终端连接

本教程介绍如何在 macOS 和 Linux 系统中使用内置终端通过 SSH 连接到你的 GoMami VPS。

前置条件

  • 已购买并部署好的 VPS 实例
  • 服务器 IP 地址和 root 密码(可在控制面板中查看)
  • macOS 或 Linux 系统

连接步骤

1. 打开终端

  • macOS — 打开 Terminal.app(位于 应用程序 > 实用工具)
  • Linux — 打开系统终端(通常快捷键为 Ctrl + Alt + T

2. 执行 SSH 命令

ssh root@your_server_ip

your_server_ip 替换为你的服务器实际 IP 地址。

3. 首次连接确认

首次连接时,终端会提示你确认服务器指纹:

The authenticity of host 'your_server_ip' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

输入 yes 并回车。

4. 输入密码

root@your_server_ip's password:

输入你的 root 密码(输入时不会显示字符,这是正常的),按回车确认。

5. 连接成功

看到类似以下内容说明连接成功:

Welcome to Ubuntu 24.04 LTS
root@hostname:~#

使用 SSH 密钥连接

如果已配置 SSH 密钥,可以免密码登录:

# 使用默认密钥
ssh root@your_server_ip

# 指定密钥文件
ssh -i ~/.ssh/id_ed25519 root@your_server_ip

使用 SSH 配置文件

为了方便连接,可以在 ~/.ssh/config 中添加配置:

Host my-vps
HostName your_server_ip
User root
IdentityFile ~/.ssh/id_ed25519

之后只需执行:

ssh my-vps

常用 SSH 选项

选项说明
-p 端口号指定非默认端口
-i 密钥文件指定私钥文件
-v显示调试信息
-o ConnectTimeout=10设置连接超时时间

连接失败排查

如果无法连接,请检查:

  1. 服务器是否运行中 — 在 控制面板 确认状态
  2. IP 地址是否正确 — 仔细核对 IP
  3. 网络是否可达 — 执行 ping your_server_ip
  4. SSH 端口是否开放 — 默认为 22 端口
  5. 防火墙规则 — 确认未阻止 SSH 端口
提示

如果 SSH 无法连接但 ping 通,可以通过 VNC 控制台 登录检查 SSH 服务状态。

下一步