top of page

LBSocial

OpenClaw + VS Code SSH:在 VS Code 中管理您的 Google Cloud 虚拟机

已更新:4月11日

随着项目规模的扩大,直接通过 Linux 命令行管理 AI 智能体框架会变得越来越繁琐。在本教程中,我们将向您展示如何设置 OpenClaw VS Code SSH 连接,以安全地管理运行在 Google Cloud 上的虚拟机 (VM)。这种设置让文件管理变得更加简单,允许您直接在本地浏览器中直观地浏览内存、编辑技能、检查凭据并启动 OpenClaw Mission Control 仪表板。


OpenClaw + VS Code SSH:在 VS Code 中轻松管理您的谷歌云虚拟机

💡 提示:本视频已内置中文配音,如需手动切换请跳转至 YouTube 原站。



夯实您的 OpenClaw VS Code SSH 基础


如果您一直关注我们之前的教程,您就会知道 OpenClaw 有多强大。我们之前已经介绍了如何 使用 OpenClaw + Google Cloud:构建 24/7 个人 AI 助手,以及如何将其与 OpenClaw + GitHub:打造真正的 AI 队友 集成。


然而,随着您添加更多功能——例如当我们设置 OpenClaw + Google Workspace CLI:构建管理 Gmail、文档与课堂的 AI 智能体 时——通过标准命令行管理这些复杂的配置会变得很棘手。通过将 VS Code 连接到您的 Google Cloud 虚拟机,您可以使用功能强大且直观的 IDE 来控制您的 AI 智能体。


Diagram showing Gemini AI between VS Code and OpenClaw Dashboard on Google Cloud. Includes "SSH Connect" and "Manage & Visualize" steps.
Architecture diagram illustrating how VS Code connects via SSH to the OpenClaw VM on Google Cloud for seamless file management and dashboard visualization.

第 1 步:本地环境设置 (Google Cloud CLI)


首先,您需要在本地电脑上安装 Google Cloud CLI (gcloud)。您可以在此处找到官方安装指南:安装 Google Cloud CLI


请注意,这与 Google Workspace CLI 不同。Workspace CLI 控制您的 Gmail 和日历等 Google Workspace 应用,而 Google Cloud CLI 则用于控制您 Google Cloud 账号上的基础设施和项目。



安装完成后,我们需要授权您的本地机器,指定要管理的项目,并检查正在运行的虚拟机。打开本地终端并运行以下命令:


# Authorize your local gcloud CLI
gcloud auth login

# Check your authorization
gcloud auth list

# List your projects to find the one hosting your VM
gcloud projects list

# Set your active project (Replace with your actual project ID)
gcloud config set project <YOUR_PROJECT_ID>

# Set your compute zone
gcloud config set compute/zone us-central1-a

# List instances to verify your VM is running
gcloud compute instances list

第 2 步:配置 SSH 和 VS Code


完成 gcloud CLI 身份验证并指向我们的项目后,我们现在可以测试连接并导出 SSH 配置供 VS Code 使用。

在终端中运行以下命令:


# Test the SSH connection via gcloud (Replace with your VM name)
gcloud compute ssh <YOUR_USER_NAME>@<YOUR_VM_NAME>

# Export the SSH configuration to your local machine
gcloud compute config-ssh

接下来,设置 VS Code:

  1. 在本地电脑上安装 VS Code。

  2. 前往扩展选项卡,搜索“SSH”,并安装 “Remote - SSH” 扩展。

  3. 打开新生成的 SSH 配置文件。

  4. 重要提示:默认用户名可能会被设为您的本地 Windows 用户名。您必须将其更改为您的 Google Cloud 账号用户名,以便 VS Code 正确连接。


Visual Studio Code window showing an SSH config file. Includes settings for remote connection to Google Compute Engine. Text and comments visible.
Configuring the Remote - SSH extension in VS Code by editing the local SSH configuration file to point to the Google Cloud VM.

保存后,使用 Remote SSH 扩展通过生成的密钥连接到您的虚拟机。您现在可以直接在 VS Code 中读取和修改文件了。




第 3 步:管理 OpenClaw 技能与文件


连接成功后,管理智能体文件就变得轻而易举了。导航至 .openclaw 文件夹并打开 workspace 目录。


在这里,您可以直观地浏览所有智能体的内存、工具和配置。例如,如果您想修改我们在 OpenClaw Skills:指导 AI 智能体进行数据分析 教程中构建的数据分析能力,只需点击技能文件并像编辑本地文件一样进行编辑即可。您还可以查看智能体的 .md 内存文件、身份“灵魂 (soul)”以及提供的工具。


Visual Studio Code showing a file named SKILL.md open with text "Autonomous Data Scientist Skill." Terminal displays "Gateway online."
The VS Code Explorer sidebar allows you to easily navigate your OpenClaw VM's file structure, including memories, skills, and credentials.

第 4 步:启动并监控仪表板


这种设置的最大优势之一是 VS Code 集成的终端和内置的端口转发功能。打开仪表板可以为您提供强大的图形用户界面,用于控制您的 OpenClaw 设置。


  1. 在 VS Code 中打开一个新终端,直接在虚拟机上运行命令。

  2. 运行 openclaw update 检查更新。

  3. 运行 OpenClaw 仪表板启动 Web 界面。


openclaw update
openclaw dashboard

此命令将输出一个带有安全令牌的 URL。由于 VS Code 会自动将远程虚拟机的活动端口转发到本地机器,您可以直接将该 URL 复制并粘贴到本地 Chrome 浏览器中。切记:请勿将此令牌 URL 分享给任何人!


Web interface displaying "OpenClaw Skills" with options to filter and manage installed skills. Tabs and toggle switches are visible.
The OpenClaw Mission Control Dashboard is securely accessed via a local browser through VS Code port forwarding.

通过这个图形界面,您可以毫不费力地检查 OpenClaw 虚拟机的状态,并查看:


  • 您的 Telegram 频道连接和活动会话。

  • Token 使用情况和成本;例如,使用 Gemini 3.1 Pro,一个月处理 300 多条消息的成本不到 20 美元。

  • 详细的分析显示,OpenClaw 在输入上消耗了大量 Token,因为它会不断搜索对话内容。

  • 任何当前计划的任务。


随着您的 OpenClaw 设置变得更加先进,将 VS Code 连接到您的 Google Cloud 虚拟机为管理技能、凭据和实时会话提供了更坚实的基础。




留言


bottom of page