Alright, let me walk you through this. I remember my first time moving a Node.js application like OpenClaw from my cozy local machine to a remote server. It felt like a big leap, but once you break it down, it’s incredibly satisfying to see your bot running 24/7 in the cloud. I’ve done this exact migration to Hetzner Cloud for a few projects, and I can tell you, their Ubuntu servers are a solid choice.
Affiliate Disclosure: As an Amazon Associate, we earn from qualifying purchases. This means we may earn a small commission when you click our links and make a purchase on Amazon. This comes at no extra cost to you and helps support our site.
This guide assumes you’ve already got OpenClaw running locally and have its `config.json` file ready.
## Before You Start: Local Machine Prep
Before we even touch the VPS, there are a couple of things you need to secure from your local OpenClaw setup:
1. **Your `config.json` file:** This is crucial. It contains all your API keys, Telegram bot token, admin IDs, and other critical settings. Copy it somewhere safe on your local machine. **Do not** commit this file to a public Git repository!
2. **Any custom data:** If your OpenClaw instance generates or relies on specific files or a `data` directory, make sure to back those up too. For a fresh install, `config.json` is usually the only essential.
## Step 1: Provisioning Your Hetzner VPS and Initial SSH Setup
First things first, let’s get your server online and secure your access.
1. **Spin up a Server on Hetzner:**
* Log in to your Hetzner Cloud console.
* Click “Add Server.”
* Choose your location (Frankfurt, Ashburn, etc.).
* Select **Ubuntu 22.04 LTS** (or the latest LTS version available).
* Pick a server type. For OpenClaw, a `CPX11` or `CPX21` (2GB RAM) is usually more than enough.
* **Crucially, add your SSH key.** If you don’t have one, generate it on your local machine:
bash
ssh-keygen -t rsa -b 4096 -C “your_email@example.com”
Follow the prompts. Then, display your public key:
bash
cat ~/.ssh/id_rsa.pub
Copy the entire output and paste it into Hetzner’s “SSH Keys” section when creating a new key. This is how you’ll securely log in.
* Give your server a name and click “Create & Buy Now.”
2. **Initial Server Access (SSH):**
Once your server is active, Hetzner will show you its IP address. You’ll log in as the `root` user initially.
bash
ssh root@YOUR_SERVER_IP_ADDRESS
If this is your first time connecting to this IP, you’ll be asked to confirm the authenticity of the host. Type `yes` and press Enter.
3. **Basic Server Security & User Setup:**
I always do this immediately. Running everything as `root` is a bad practice.
* **Update and Upgrade:**
bash
sudo apt update && sudo apt upgrade -y
* **Create a new user (e.g., `openclawuser`):**
bash
adduser openclawuser
Follow the prompts to set a strong password and fill in (or skip) the user information.
* **Grant sudo privileges to the new user:**
bash
usermod -aG sudo openclawuser
* **Copy your SSH key to the new user:** This lets you log in as `openclawuser` directly using your SSH key.
bash
rsync –archive –chown=openclawuser:openclawuser ~/.ssh /home/openclawuser
*Self-correction:* Make sure the `.ssh` directory and `authorized_keys` have the correct permissions.
bash
chmod 700 /home/openclawuser/.ssh
chmod 600 /home/openclawuser/.ssh/authorized_keys
* **Exit root and log in as your new user:**
bash
exit
ssh openclawuser@YOUR_SERVER_IP_ADDRESS
From now on, you should do all your work as `openclawuser`.
* **Enable Firewall (UFW):**
bash
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status
You should see `Status: active` and `OpenSSH (v6) ALLOW Anywhere`. If your bot needs to access other ports later (e.g., a web interface), you’ll `sudo ufw allow PORT/tcp`.
## Step 2: Installing Node.js and Git
OpenClaw is a Node.js application, so we need Node.js and its package manager (npm) on the server. We’ll also need Git to clone the repository.
1. **Install Node.js (LTS version):**
I use NodeSource’s PPA for a stable, up-to-date version.
bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash –
sudo apt-get install -y nodejs
2. **Verify Node.js and npm installation:**
bash
node -v
npm -v
You should see version numbers (e.g., `v18.x.x` and `9.x.x`).
3. **Install Git:**
bash
sudo apt-get install -y git
4. **Verify Git installation:**
bash
git –version
## Step 3: Installing OpenClaw
Now let’s get the
Frequently Asked Questions
What are the essential prerequisites for moving OpenClaw to a VPS?
You need an active OpenClaw installation, a configured VPS with SSH access, and fundamental command-line skills. Ensure data backup before starting the migration process.
Why should I move OpenClaw from my local machine to a VPS?
Moving to a VPS offers enhanced accessibility, dedicated resources, improved uptime, and better performance for your OpenClaw instance, making it available 24/7 reliably.
Is the 30-minute migration timeframe realistic for all users?
The 30-minute estimate is achievable for standard setups with a pre-configured VPS and basic CLI familiarity. Complex installations or troubleshooting might slightly extend the duration.
Leave a Reply