---
title: "如何在 Linux VPS 远程服务器上从零开始安装、部署与配置 Hermes Agent"
description: "在本篇非常详尽的实战教程中，我们将一步步向您展示如何在远程 Linux VPS 服务器上成功安装与部署 Hermes Agent，并实现 24 小时稳定常驻运行。我们还会手把手教您如何通过自定义的 Telegram 机器人，快速与Hermes进行无缝对接，轻松实现自动化的任务管理，确保系统能随时在线响应。"
canonical_url: "https://techvoyage.dev/zh/article/how-to-setup-hermes-on-remote-server"
last_updated: "2026-10-20T09:53:52.091Z"
---

## 为什么在远程 VPS 上托管 Hermes Agent？

由于 Hermes Agent 能够执行后台任务、调度作业以及响应 webhook 调用，我们需要一台机器保持 24/7 全天候待命。本地设备可能会断电、断网，或者面临硬件资源耗尽的风险。而远程服务器（VPS）则能保证 99% 以上的在线率（Uptime），并在需要时轻松对计算资源进行弹性扩容。

目前市面上有好几家性价比极高的虚拟专用服务器（VPS）提供商，比如 Hetzner、Hostinger 和 Contabo。我们已经使用 Contabo 有一段时间了，到目前为止，它的表现非常稳定和出色。

## 如何在 Linux VPS 上配置 Hermes Agent

### 第一步：连接到您的 VPS

打开终端并使用 SSH 登录您的远程服务器：

```bash
ssh root@your_server_ip
```

![在终端中通过 SSH 连接到 Linux VPS 服务器](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/vps-terminal-ssh-connection.webp)

确保服务器的软件包都是最新的：

```bash
sudo apt update && sudo apt upgrade -y
```

添加一个新用户 `hermes`，或者您自定义的其他用户名：

```bash
sudo adduser hermes 
sudo passwd hermes
```

关闭 `root` 用户的密码登录以增强安全性：

1. 打开 SSH 配置文件：

```bash
sudo nano /etc/ssh/sshd_config
```

1. 找到 `PermitRootLogin` 这一行，将其值修改为 `no`：

```text
PermitRootLogin no
```

1. 保存文件并重启 SSH 服务：

```bash
sudo systemctl restart ssh
```

### 第二步：安装 Hermes Agent

运行以下命令：

```bash
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
```

![在终端中运行 Hermes Agent 的一键安装脚本](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-agent-installation-terminal.webp)

安装完成后，输入以下命令验证是否安装成功：

```bash
hermes --version
```

运行 `hermes setup` 命令行工具来配置 Hermes Agent：
![在终端中运行 hermes setup 命令开始向导配置](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-agent-setup-wizard.webp)

选择大语言模型（LLM）提供商，我们可以先选择 `DeepSeek`，后续再根据需要添加其他模型。
![在 Hermes 设置中选择 DeepSeek 作为 LLM 大模型提供商](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-llm-provider-selection.webp)

输入您的 `DeepSeek` API 密钥：
![在终端命令行中输入 DeepSeek API 密钥](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-enter-api-key.webp)![成功验证并确认大模型提供商的 API 密钥](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-api-key-success.webp)
在运行 Hermes Agent 的环境选项中选择 `local machine`：
![选择 local machine 本地设备作为 Hermes Agent 的执行环境](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-select-local-machine.webp)
在通信渠道（Channels）中选择 `Telegram`，其他渠道可以在后续随时配置。
![在 Hermes 设置中选择 Telegram 作为通信管道渠道](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-select-telegram-channel.webp)

### 第三步：与 Telegram 进行集成

选择选项 `[2]` 来使用 Telegram 机器人。
![选择选项开始集成并配置 Telegram 机器人](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-bot-integration-option.webp)

打开 `Telegram` 并搜索 'BotFather' 官方账号。
![在 Telegram 应用中搜索官方 BotFather 账号](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-search-botfather.webp)

点击 `Open` 打开与 'BotFather' 的对话框。
![在 Telegram 中打开与 BotFather 的对话框](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-open-botfather-chat.webp)

点击 `Create a New Bot`（或输入 `/newbot` 指令）。
![向 BotFather 发送 /newbot 指令以创建全新的机器人](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/botfather-create-new-bot.webp)

按照提示填写名称和用户名，完成机器人的创建。
![配置新 Telegram 机器人的昵称和唯一用户名](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/botfather-bot-details-configured.webp)

点击 `Copy` 复制机器人 Token（令牌），并将其粘贴回终端中。
![复制新创建的 Telegram 机器人的 HTTP API 访问 Token](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/botfather-copy-http-api-token.webp)

获取您的 `Telegram` 账号 ID 并将其添加到允许访问的用户列表（'Allowed user list'）中：

- 在 `Telegram` 中搜索 '@raw_data_bot'。
![在 Telegram 中搜索 raw data bot 机器人以检索账号 ID](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-search-raw-data-bot.webp)
- 点击进入 `RawDataBot` 并点击 Start（开始）按钮。您的用户 ID 将显示在 `P.S. Your ID:` 后面。
![启动 RawDataBot 机器人以获取当前用户的账号 ID](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-raw-data-bot-user-id.webp)
- 复制该用户 ID 并粘贴到终端中。

由于我们在云端运行此服务，我们希望它能在系统启动时自动运行。
![配置 Hermes systemd 服务开机自启自动运行的选项](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-autostart-service-option.webp)
将其他设置均保持默认值即可：
![在终端设置中将各项基础配置保持默认推荐值](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-leave-defaults-1.webp)![在 Hermes 配置向导中完成默认选项的设置](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/hermes-setup-leave-defaults-2.webp)

## 使用 Telegram 机器人测试您的 Hermes Agent

运行以下命令启动 `hermes gateway` 服务：

```bash
hermes gateway
```

打开 `Telegram`，将刚刚创建的机器人，例如 '@tech_cloud_hermes_bot'，添加到对话中。

- 在对话框中输入 `/new` 启动一个新的 `Hermes Agent` 对话会话。
![在 Telegram 聊天框中输入 /new 指令开启新的智能体对话会话](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-chat-hermes-new-session.webp)
- 输入 `/commands` 指令将列出所有可用的操作命令。
![在 Telegram 聊天框中输入 /commands 指令查看可用操作指令列表](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-chat-hermes-commands-list.webp)
- 输入 `/model` 指令即可查看当前可用的 LLM 大模型列表。
![在 Telegram 聊天框中输入 /model 指令查看可切换的 LLM 列表](https://inimages.techvoyage.dev/articles/How%20to%20Setup%20Hermes%20on%20Remote%20Server/telegram-chat-hermes-model-selection.webp)

## 将 Hermes Gateway 配置为后台常驻服务

创建 systemd 守护进程服务文件：

```shell
sudo nano /etc/systemd/system/hermes-gateway.service
```

粘贴以下配置，注意将 `/home/hermes` 中的 `hermes` 替换为您自己的用户名：

```ini
[Unit]
Description=Hermes Gateway
After=network.target

[Service]
User=hermes
WorkingDirectory=/home/hermes
ExecStart=/home/hermes/.local/bin/hermes gateway
Restart=always
RestartSec=10
Environment=PATH=/home/hermes/.local/bin:/usr/local/bin:/usr/bin:/bin

[Install]
WantedBy=multi-user.target
```

启用并启动该背景服务：

```shell
sudo systemctl daemon-reload
sudo systemctl enable hermes-gateway
sudo systemctl start hermes-gateway
sudo systemctl status hermes-gateway
```

## 总结与展望

在本文中，我们主要分享了如何在云端服务器上搭建并配置 Hermes Agent，并通过 Telegram 实现与其双向的高效沟通。让 Hermes Agent 运行在远程 VPS 上，能够为您打造一个 24 小时永不下线的、真正的 AI 数字化个人助手。
