---
title: "如何在 Linux VPS 遠端伺服器上從零開始安裝、部署與設定 Hermes Agent"
description: "在本篇詳細的實戰教學中，我們將逐步向您展示如何在遠端 Linux VPS 伺服器上成功安裝與部署 Hermes Agent，並實現 24 小時不間斷的穩定運行。我們還會手把手教您如何透過自訂的 Telegram 機器人，快速與Hermes進行無縫對接，輕鬆實現自動化的工作流程管理，確保系統隨時在線回應。"
canonical_url: "https://techvoyage.dev/tw/article/how-to-setup-hermes-on-remote-server"
last_updated: "2026-10-20T09:53:53.558Z"
---

## 為什麼在遠端 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：
![In terminal, run hermes setup command to initiate setup wizard](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 數位化個人助理。
