Ubuntu 24.04: Deploy an Open-Source AI Gateway and Connect Cloud LLMs
Learn how to deploy an OpenClaw AI gateway on Ubuntu 24.04, configure a cloud-hosted language model provider, and access the gateway through an encrypted SSH tunnel. This guide covers Node.js setup, installation troubleshooting, API configuration, connection testing, and considerations for long-running deployments.
1. Deployment Overview and Prerequisites
An open-source AI gateway provides a way to connect your own tools to cloud-hosted large language models. This guide uses an Ubuntu 24.04 server to run a Node.js-based gateway, connects it to a remote model inference API, and uses SSH port forwarding for encrypted access from your local computer.
Before you begin, make sure you have:
- An Ubuntu 24.04 server: A cloud instance or physical machine. The commands assume a root session; if you use a regular account, make sure it has sudo privileges where required.
- Model API credentials: An API key from a cloud model provider with access to the model you intend to use. Trial availability and usage limits depend on the provider.
- A local SSH client: Windows PowerShell, macOS Terminal, or a Linux terminal with SSH support.
- Network connectivity: The server must be able to download dependencies and reach the model provider’s API.
2. Set Up the Node.js Runtime
Node.js-based gateways such as OpenClaw require a compatible runtime version. The Node.js version available from Ubuntu’s default repositories may not meet the gateway’s requirements. Using nvm, the Node Version Manager, makes it easier to install and switch between Node.js versions.
Run the following commands:
# Download and run the nvm installation scriptcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash# Load the updated shell environmentsource ~/.bashrc# Install Node.js 22 LTSnvm install 22# Set the default Node.js versionnvm alias default 22# Verify the installationnode --version
The final command should return a version such as v22.x.x. If it does not, reload your shell configuration and check your network or proxy settings.
Common installation issues
nvmcommand not found: Your shell may not have loaded the changes in~/.bashrc. Runsource ~/.bashrcagain or open a new terminal session.- Compilation errors: If installation falls back to compiling Node.js from source, servers with less than 1 GB of memory may run out of resources. Temporarily adding swap space or using a precompiled binary can help.
3. Install and Verify the AI Gateway
With Node.js installed, use npm to install OpenClaw globally:
npm install -g openclaw@latest
The installation output may include deprecated dependency warnings. These warnings do not necessarily mean the installation has failed.
Troubleshoot installation errors
An ENOTEMPTY error can indicate that files from an earlier installation remain in the target directory. The following cleanup commands apply if OpenClaw is installed at the root-user path shown below. Confirm the location before deleting it:
rm -rf /root/.npm-global/lib/node_modules/openclawnpm cache clean --forcenpm install -g openclaw@latest
After installation, check that the command is available:
openclaw --version
A version string, such as 2026.3.2, confirms that the executable is accessible through your shell’s PATH. The version returned depends on the installed release.
4. Configure the Cloud Model Provider
OpenClaw provides an interactive configuration workflow. Start it with:
openclaw config
Follow the prompts to configure your provider. Menu labels may vary by release.
- Choose the provider type: Select Add custom provider to configure a provider that is not included in the preset list.
- Name the provider: Enter an identifier such as
zhipuorglm. This name identifies the provider in subsequent model configuration. - Enter the API base URL: Supply the provider’s OpenAI-compatible endpoint. A typical placeholder is
https://api.example.com/v1; replace it with the address in your provider’s API documentation. - Enter authentication credentials: Paste an API key with permission to call the selected service. Keys beginning with
sk-are common, but the format depends on the provider.
The configuration workflow saves the endpoint and authentication details. Restrict access to the configuration file so that only its owner can read and write it.
If your installation stores the configuration at the path below, run:
chmod 600 ~/.openclaw/config.json
Confirm the actual configuration-file location for your installed version before applying the command.
5. Access the Gateway Securely with SSH
Exposing a cloud-hosted management interface directly to the internet increases its exposure to automated scans and attacks. SSH port forwarding lets you access the interface over an encrypted connection without publicly exposing its web port.
Run the following command on your local computer:
ssh -L 3000:localhost:3000 root@your_server_ip
Replace your_server_ip with your server’s address.
This forwards connections to local port 3000 through SSH to port 3000 on the server’s loopback interface. With the gateway running and listening on that server-side port, open:
http://localhost:3000
Keep the SSH session open while using the interface. The tunnel forwards traffic; it does not start the gateway. Confirm the gateway’s actual listening port for your installed version.
Additional security measures
- Use SSH keys instead of passwords: Upload your public key with
ssh-copy-id, verify key-based access, and then disable password login. - Consider TOTP-based two-factor authentication: Google Authenticator or a similar tool can provide an additional authentication factor.
- Restrict SSH access: Use ufw or iptables to limit connections to trusted source IP addresses.
6. Test the Model Connection
Once the gateway is running and the provider is configured, open the management interface, select the configured cloud model, and send a test message. A successful request should return a model response, streamed if supported by the configuration.
If the request fails, troubleshoot in this order:
- Check the API key and account status: Review request records in the provider’s console. Confirm that the key is valid and that account credit or rate limits are not blocking requests.
Check network connectivity: From the server, test whether the provider’s host is reachable:
curl -I https://api.example.com
Replace the placeholder with your provider’s host. An HTTP response helps confirm connectivity, but does not by itself verify API authentication or model access.
Inspect gateway logs:
openclaw logs
Look especially for HTTP
401errors, which typically indicate authentication problems, and429errors, which commonly indicate rate limiting.
7. Considerations for Long-Running Deployments
For a gateway that needs to remain available over time, consider the following:
- Process supervision: Use pm2 or systemd to manage the gateway process, start it at boot, and restart it after a crash.
- Reverse proxy: If you need web access beyond an SSH tunnel, place Nginx in front of the gateway to handle HTTPS and access controls rather than exposing the Node.js port directly.
Regular updates: Review upstream release notes and update the installation to receive relevant fixes and features:
npm update -g openclaw
8. Conclusion
This setup connects an open-source AI gateway on Ubuntu 24.04 to a cloud-hosted language model API. The workflow covers installing Node.js, deploying OpenClaw, configuring provider credentials, accessing the management interface through SSH, and validating model requests.
For ongoing use, combine secure access with process supervision and regular maintenance. Depending on your requirements and the gateway’s supported capabilities, you can later explore multi-model load balancing and function-call orchestration.
