Self-Hosting an AI Assistant on a Linux Server: Setup and LLM Integration Guide
A practical guide to deploying a self-hosted AI assistant platform on an Ubuntu 24.04 server. This tutorial covers installing a JavaScript runtime, setting up the platform via a package manager, configuring a custom LLM provider with API keys and default models, and securely accessing the web console through SSH port forwarding. It also includes troubleshooting tips, long-running service configuration, and security hardening practices.
1. Overview
A self-hosted AI assistant platform runs on your own server, connects to one or more LLM services through a unified configuration, and provides a browser-based console, command-line interaction, and adapters for third-party messaging channels. Compared with using online web pages directly, self-hosting makes it easier to centrally manage conversation settings, access permissions, and the runtime environment, while also paving the way for future automation tasks.
The deployment approach used in this guide:
- Prepare a server running a Linux 24.04 distribution.
- Install a recent JavaScript runtime.
- Install the assistant platform with a package manager.
- Add a model provider through the interactive configuration wizard.
- Configure the API endpoint, key, and default model.
- Make the service listen only on the server’s local address.
- Use SSH port forwarding to securely access the admin console from a local browser.
Note that all model service URLs, model names, and API keys in this article are placeholders. In practice, always refer to the official documentation of the service you use.
2. Preparation
1. Server Requirements
The server should meet the following baseline:
- 64-bit Linux, version 24.04 or an equivalent release
- Administrator privileges, or a user account with software installation and service management rights
- Access to software package repositories and the model service API
- At least a few GB of free disk space
- A stable SSH connection
- For long-term use, a static public address or an internal jump-host setup is recommended
The platform itself typically does not run model inference, so CPU and memory requirements depend mainly on the platform components, the number of concurrent sessions, and any plugins in use. If inference happens remotely, modest hardware is enough for personal testing. If you later host models locally, plan for more memory, GPU capacity, and storage based on model size.
2. Prepare Model Service Credentials
Create an API key in the model provider’s console and confirm the following details:
- The API base URL
- The compatible API format
- Available model names
- Per-request limits
- Concurrency limits and remaining quota
- Whether extra request headers or region-specific settings are required
API keys are sensitive credentials. Never commit them to public repositories, screenshots, tickets, or chat logs. Store them in a restricted-permission configuration file on the server and rotate them regularly.
3. Installing the JavaScript Runtime
This type of platform depends on a JavaScript runtime. The version in the default system repositories is often outdated, which can cause dependency installation failures or runtime incompatibilities. Use a version manager to install an LTS release instead:
curl -o- https://example.invalid/runtime-manager/install.sh | bashsource ~/.bashrcruntime-manager install 22runtime-manager alias default 22runtime --versionpackage-manager --version
The commands above use neutral placeholders — replace them with the actual runtime version manager and its commands. After installation, verify:
- The runtime version meets the platform’s requirements
- The package manager works correctly
- The current shell has loaded the version manager environment
- Environment variables are consistent for both root and regular users
If the version command reports “command not found,” the shell usually hasn’t reloaded its configuration. Reconnect via SSH or manually source your user profile.
4. Installing the Self-Hosted Assistant Platform
Once the runtime is ready, install the platform globally:
package-manager install --global assistant-platform@latest
Verify the installation:
assistant-platform --version
If you get a permissions error, don’t grant write access to system directories. A safer approach is to point the global package directory to a user-writable location:
mkdir -p ~/.local/packagespackage-manager config set global-prefix ~/.local/packagesexport PATH="$HOME/.local/packages/bin:$PATH"
To make the PATH persistent, add it to your shell startup file, then log in again.
Common Installation Issues
1. Directory-not-empty or leftover-file errors
This usually happens when a previous installation was interrupted and left files behind. Confirm the directory belongs to this platform, then remove it:
rm -rf ~/.local/packages/lib/node_modules/assistant-platformpackage-manager cache cleanpackage-manager install --global assistant-platform@latest
Double-check the path before deleting anything to avoid removing other applications.
2. Dependency warnings
Warnings about outdated or incompatible dependencies don’t necessarily mean the installation failed. Focus on the final exit status and whether the version command runs. If the program starts but keeps throwing dependency errors during runtime, switch to a runtime version supported by the platform.
3. Slow installation or timeouts
Check the following:
- Server DNS and network connectivity
- Whether the package repository URL is reachable
- Whether the system clock is accurate
- Clear stale caches and retry
- Avoid repeatedly interrupting the install on unstable networks
5. Configuring the Model Service
Start the interactive configuration wizard:
assistant-platform config
Follow the prompts to complete these steps:
1. Add a Custom Model Provider
Choose “Add custom provider” or the equivalent option, and enter a recognizable name, for example:
provider-main
The name is only for local identification and doesn’t need to match the provider’s actual name.
2. Enter the API Base URL
Input the API base URL provided by the model service, for example:
https://api.example.invalid/v1
The real URL must come from the provider’s documentation. A common mistake is entering the full chat completion path, a web page URL, or the admin dashboard URL as the base URL. If the platform appends request paths automatically, enter only the base URL to avoid duplicated paths.
3. Enter the API Key
Paste the key into the wizard. The terminal may not display characters as you type — this is normal. After configuration, avoid debug commands that print the key to the screen.
4. Choose the Default Model
Enter the exact model identifier provided by the service, for example:
model-name-placeholder
The model name must match the identifier in the API documentation exactly, including casing, hyphens, and version suffixes. If the model doesn’t exist, you’ll typically see errors like “model unavailable” or “resource not found.”
5. Save and Verify
After configuration, run the platform’s test command or start the interactive session:
assistant-platform statusassistant-platform chat
Send a simple message and confirm you get a normal reply. If the request fails, check the API URL, model name, and API key first, then network connectivity and server-side limits.
6. Accessing the Web Console via SSH Port Forwarding
To reduce exposure, configure the web service to listen only on the server’s local address, for example:
127.0.0.1:8080
Never expose the admin port directly to the public internet. On your local machine, set up SSH port forwarding:
ssh -N -L 8080:127.0.0.1:8080 user@server-address
Parameter breakdown:
-N: forward ports only, without executing a remote command-L: create a local-to-remote port mapping- The first
8080: local listening port - The second
8080: the web service port on the server user@server-address: your login user and server address
Keep this terminal window open, then open in your local browser:
http://127.0.0.1:8080
The browser connects to a local port, and SSH encrypts and forwards requests to the server. Compared with exposing a public port, this approach reduces the risk of port scanning, brute-force attacks, and unauthorized access.
If local port 8080 is already in use, change the local port:
ssh -N -L 18080:127.0.0.1:8080 user@server-address
Then visit:
http://127.0.0.1:18080
7. Running the Service Long-Term
For testing, you can start the platform directly in a terminal, but the process may terminate when the SSH session closes. For production or long-term use, host the service with a system service manager, a process manager, or a container.
Regardless of the method, configure:
- Automatic restart
- stdout and stderr logging
- Working directory
- Runtime user
- Environment variables
- Service start order
- Resource limits
Avoid running the application under an administrator account long-term. After testing, create a dedicated regular user and restrict configuration files, log directories, and runtime directories to that user.
8. Security Hardening Tips
- Grant API keys minimal permissions; revoke and regenerate immediately if leaked.
- Restrict configuration file permissions to the owner only:
chmod 600 ~/.config/assistant-platform/config.json
- Use SSH key authentication and disable unnecessary password logins.
- Bind the web admin service to localhost only, and prefer SSH port forwarding.
- Update the platform and its dependencies regularly, but back up your configuration first.
- Don’t log full request headers, keys, or sensitive conversation content.
- Review permissions for external plugins, automation scripts, and messaging channels.
- Set up a basic firewall on the server and only open essential ports such as SSH.
9. Troubleshooting Order
When the model can’t be called, diagnose in this order:
- Run the version command to confirm the platform starts.
- Check that the configuration file exists and is correctly formatted.
- Confirm the API URL is the base URL.
- Verify the model identifier is accurate.
- Check whether the key is expired, revoked, or incompletely copied.
- Use network test commands to confirm the server can reach the API.
- Check the HTTP status codes in the platform logs.
- Based on the error type, determine whether it’s an authentication failure, wrong path, rate limiting, insufficient quota, or a server-side issue.
Once these steps are complete, the self-hosted assistant on your server is ready to use from a local browser. The core principles of this setup: a stable runtime environment, accurate model configuration, well-protected keys, and admin ports never exposed to the public internet.
