Run OpenClaw in a Daytona Sandbox via CLI
This guide walks you through setting up OpenClaw inside a Daytona sandbox and configuring Telegram and WhatsApp channels.
Running OpenClaw in a Daytona sandbox keeps your AI assistant isolated from your local machine, provides a secure environment for code execution, and ensures your bot stays online 24/7 without tying up your personal computer.
Prerequisites
Section titled “Prerequisites”- Daytona account and API key (Get it from Daytona Dashboard)
- Local terminal (macOS, Linux, or Windows)
Install the Daytona CLI
Section titled “Install the Daytona CLI”brew install daytonaio/cli/daytonapowershell -Command "irm https://get.daytona.io/windows | iex"Authenticate with Daytona
Section titled “Authenticate with Daytona”Log in to your Daytona account using your API key:
daytona login --api-key=YOUR_API_KEYReplace YOUR_API_KEY with your actual Daytona API key.
Create a Sandbox
Section titled “Create a Sandbox”Create a sandbox for running OpenClaw:
daytona sandbox create --name openclaw --snapshot daytona-medium --auto-stop 0OpenClaw comes preinstalled in the default Daytona snapshot, so the command above is all you need.
Connect to the Sandbox
Section titled “Connect to the Sandbox”SSH into your sandbox:
daytona ssh openclawRun OpenClaw Onboarding
Section titled “Run OpenClaw Onboarding”Configure OpenClaw in one command. Run this inside the SSH session:
openclaw onboard --non-interactive --accept-risk \ --anthropic-api-key YOUR_ANTHROPIC_KEY \ --skip-daemon --skip-channels --skip-skills --skip-hooks --skip-health--skip-daemonmatters here: Daytona sandboxes have no service manager, so you start the gateway manually below.- Using a different provider? Swap the key flag (
--openai-api-key,--openrouter-api-key, and so on). Runopenclaw onboard --helpfor the full list. - Channels, skills, and hooks are skipped now and configured later.
Onboarding configures a gateway auth token. Print it from the sandbox:
node -p "require(process.env.HOME + '/.openclaw/openclaw.json').gateway.auth.token"Save this token - you’ll need it to connect to the dashboard.
Allow Dashboard Access Through the Preview URL
Section titled “Allow Dashboard Access Through the Preview URL”The gateway accepts browser connections only from allowed origins, and Daytona’s preview proxy sits in front of it - configure both before starting the gateway.
In your local terminal (not inside the sandbox SSH session), get the preview URL for the gateway port:
daytona preview-url openclaw --port 18789This generates a signed preview URL that securely exposes the port. You will open it in the browser later.
Copy the URL it prints — for example https://18789-r0enfyhje6plfaaj.daytonaproxy01.net. You will open it in the browser later, and the gateway needs to know that exact origin.
Back in the sandbox SSH session, allow that origin and trust the in-sandbox preview proxy:
openclaw config set gateway.controlUi.allowedOrigins '["https://18789-r0enfyhje6plfaaj.daytonaproxy01.net"]'openclaw config set gateway.trustedProxies '["127.0.0.1"]'Replace the example URL with the one the CLI printed for your sandbox.
Start the Gateway
Section titled “Start the Gateway”Run the gateway in the background:
nohup openclaw gateway run > /tmp/gateway.log 2>&1 &The & runs the gateway as a background process, keeping your terminal free for other commands. The nohup ensures the gateway keeps running even after you close the SSH connection.
Verify it is up:
openclaw gateway healthThe command reports the gateway status, so OK means you are good to continue.
Access the Dashboard
Section titled “Access the Dashboard”The OpenClaw dashboard is a web interface for managing your assistant, monitoring connections, and configuring channels.
Open the preview URL you generated earlier in your browser, and paste your gateway token when the Control UI prompts for it (the value you printed after onboarding).
Pair Your Browser
Section titled “Pair Your Browser”OpenClaw uses device pairing as a security measure - only approved devices can connect to and control your assistant. When you first attempt to connect from the dashboard, your browser registers as a new device that needs approval.
List pending device requests:
openclaw devices listApprove your device:
openclaw devices approve REQUEST_IDReplace REQUEST_ID with the value from the Request column.
The dashboard shows a Device pairing required screen until you approve; it reconnects automatically after the approval completes.
Once connected, you should see a green status indicator - your OpenClaw is now ready to use.
Security
Section titled “Security”Running OpenClaw this way provides three layers of security:
- Preview URL: Time-limited access to the dashboard port
- Gateway token: Required to authenticate with the dashboard
- Device approval: Only approved devices can connect and control your assistant
Even if someone obtains your dashboard URL, they cannot connect without the gateway token and an approved device.
Configure Telegram
Section titled “Configure Telegram”Set up a Telegram bot to chat with OpenClaw.
Create a Telegram Bot
Section titled “Create a Telegram Bot”- Open Telegram and search for @BotFather
- Send
/start, then/newbot - Enter a name for your bot
- Enter a username for your bot
- Copy the bot token provided
Configure OpenClaw
Section titled “Configure OpenClaw”Enable Telegram and set your bot token:
openclaw config set channels.telegram.enabled trueopenclaw config set channels.telegram.botToken YOUR_BOT_TOKENVerify the configuration:
openclaw config get channels.telegramRestart the Gateway
Section titled “Restart the Gateway”pkill -f "openclaw gateway" || truenohup openclaw gateway run > /tmp/gateway.log 2>&1 &Complete Verification
Section titled “Complete Verification”- Open your bot’s chat in Telegram and click Start
- A pairing code will appear. List and approve the pairing request:
openclaw pairing list telegramopenclaw pairing approve telegram PAIRING_CODEPairing codes expire after 1 hour. You can now message your OpenClaw through Telegram.
Configure WhatsApp
Section titled “Configure WhatsApp”Set up WhatsApp to chat with OpenClaw.
Install the WhatsApp plugin
Section titled “Install the WhatsApp plugin”Unlike Telegram, WhatsApp ships as a separate plugin, so install and enable it first:
openclaw plugins install clawhub:@openclaw/whatsapp --acknowledge-clawhub-riskopenclaw plugins enable whatsapp--acknowledge-clawhub-risk accepts the ClawHub release trust prompt up front. Installing does not enable a plugin, so the enable step is required — without it the gateway reports that the channel is configured but the plugin is not trusted.
Link WhatsApp (QR)
Section titled “Link WhatsApp (QR)”From the sandbox SSH session, start the QR link flow:
openclaw channels login --channel whatsappOpen WhatsApp on your phone, go to Settings → Linked Devices → Link a Device, and scan the QR code displayed in your terminal.
Restart the Gateway
Section titled “Restart the Gateway”pkill -f "openclaw gateway" || truenohup openclaw gateway run > /tmp/gateway.log 2>&1 &Start Chatting
Section titled “Start Chatting”Send a message to yourself in WhatsApp — OpenClaw replies in the same chat, and you can give it instructions directly there.
No pairing approval is needed here: with no allowlist configured, the linked account’s own number is allowed by default. Pairing applies to unknown senders, which is why Telegram needs it but messaging yourself on WhatsApp does not.
Update OpenClaw
Section titled “Update OpenClaw”The snapshot’s global npm tree is owned by root, so plain openclaw update cannot write to it. Update from the sandbox SSH session with:
sudo env "PATH=$PATH" npm install --global openclaw@latestopenclaw doctoropenclaw doctor migrates any older config after the update. Then restart the gateway (pkill + nohup as above).