Deploy a Self-Hosted AI Assistant Platform on Ubuntu 24.04
This guide walks through deploying a self-hosted AI assistant platform on Ubuntu 24.04, covering hardware baseline, user permissions, Node.js setup, platform installation, model provider configuration, secure console access via SSH tunneling, and an acceptance checklist for operations. It also explains common installation failures and key security practices for managing API keys.
1. Why Choose a Self-Hosted AI Assistant Platform
When teams bring large language model capabilities into daily workflows, they usually run into three practical problems. First, conversation data needs to stay within a boundary they control. Second, different business scenarios require switching between models, so a unified access layer is desirable. Third, the assistant should not live only in a browser; it should extend to the terminal and instant messaging tools. This is exactly the value of a self-hosted approach: the access layer, session storage, and channel adapters run on your own server, while model services are connected on demand.
A typical self-hosted AI assistant platform provides four layers of capability: a model access layer (compatible with multiple providers and custom interfaces), a session and knowledge management layer, an interaction layer (web console and terminal interface), and a channel adapter layer (integration with common chat platforms). Understanding this layering helps you identify which layer a problem belongs to during later configuration.
2. Preparation and Planning Before Deployment
Hardware and system baseline. An Ubuntu 24.04 server with a 2-core CPU, at least 2 GB of memory, and 20 GB of free disk space is recommended. If you plan to build a local knowledge base for retrieval, increase memory to 4 GB or more. Keep the system time zone and clock synchronized to avoid token signature validation failures caused by time drift.
User and permissions. Running the application as root for an extended period is not recommended in production. Create a regular user with sudo privileges and perform all installation and runtime operations under that user:
adduser deploy && usermod -aG sudo deploysu - deploy
Network and security group. Open only the SSH port and the ports required for management. Do not expose the web console port directly to the public internet; Section 5 describes a more secure access method.
Dependency environment. The platform runs on Node.js. The version in the distribution’s default repository is often outdated, so use a version manager to install the current LTS release, which also makes switching between versions easier later:
curl -o- https://<version-manager-official-install-script-url> | bashsource ~/.bashrcnvm install 22nvm alias default 22node --version # expected output: v22.x.xnpm --version
If the server cannot reach the script URL directly, use an offline approach instead: download the Node.js LTS binary package on a machine with internet access, upload it, extract it to /usr/local, and configure PATH manually.
3. Installing the Platform and Handling Common Failures
Global installation is the fastest path:
npm install -g openclaw@latestopenclaw --version
If installation fails due to directory permissions or leftovers (a typical error indicates the directory is not empty), follow three steps: clear leftovers, clear the cache, and reinstall:
rm -rf ~/.npm-global/lib/node_modules/<package-name>npm cache clean --forcenpm install -g <package-name>@latest
A principle worth stating: deprecation warnings during installation are upstream dependency lifecycle notices and usually do not affect functionality. In contrast, ENOTEMPTY and EACCES are environment state problems that must be fixed before retrying; repeated reinstall attempts only amplify leftovers. If you install as root, npm’s default global directory is /usr/lib/node_modules, which differs from the regular user scenario, so confirm the current npm prefix first when troubleshooting.
4. Key Configuration for Connecting a Large Model Service
The platform generally provides an interactive wizard to complete model onboarding. The core requirement is to give the platform four pieces of information: provider type, API base URL, key, and model identifier.
openclaw config
Follow the prompts to select “Add custom provider,” then enter the name (for example, custom), the OpenAI-compatible API base URL provided by your chosen model service provider (in the form https://<host>/api/paas/v4), a key starting with sk-, and the model identifier (for example, a lightweight chat model name from a specific vendor). After completing the fields, run a connectivity self-check with a very short prompt to verify that authentication and network egress work.
Key security is the most easily overlooked part. Store the key in a configuration file with restricted permissions rather than in command-line history:
chmod 600 ~/.config/openclaw/config.json
Also avoid committing keys to a code repository. For team collaboration, use a key management capability or environment variable injection, and rotate keys regularly.
Model selection strategy. Lightweight models suit high-concurrency question answering and summarization, with fast responses and low cost. More capable models suit complex reasoning and long-text processing. In practice, configure multiple model entries in the platform and switch by scenario instead of making a single model handle the entire load.
5. Securely Accessing the Console via SSH Port Forwarding
When the web console listens on the local loopback address by default, the most secure remote access method is tunnel forwarding, which requires no additional public ports:
ssh -L 8080:127.0.0.1:8080 deploy@<server-address>
Then open http://127.0.0.1:8080 in your local browser. If you want the service to stay running permanently, run the platform as a system service and collect runtime metrics with a log service and monitoring alerts. Containerized deployment suits scenarios where you need to replicate environments quickly.
6. Acceptance Checklist and Operations Recommendations
- Versions and dependencies:
node --versionandopenclaw --versionreturn normal output; - Model connectivity: the wizard self-check passes and the console returns content normally;
- Security baseline: the console is not exposed to the public internet, the key file permission is 600, and SSH uses key-based login;
- Observability: log collection and basic alerting are in place, with attention to error rate and response latency;
- Backup strategy: back up configuration and session data regularly, and store sensitive fields in the configuration file in encrypted form.
After completing deployment through the process above, you do not end up with a one-off demo environment, but a private AI assistant foundation that can keep evolving: models are replaceable, channels are extensible, data boundaries are clear, and access paths always converge on a controlled channel.
