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:

    1. Prepare a server running a Linux 24.04 distribution.
    2. Install a recent JavaScript runtime.
    3. Install the assistant platform with a package manager.
    4. Add a model provider through the interactive configuration wizard.
    5. Configure the API endpoint, key, and default model.
    6. Make the service listen only on the server’s local address.
    7. 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:

    1. curl -o- https://example.invalid/runtime-manager/install.sh | bash
    2. source ~/.bashrc
    3. runtime-manager install 22
    4. runtime-manager alias default 22
    5. runtime --version
    6. package-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:

    1. package-manager install --global assistant-platform@latest

    Verify the installation:

    1. 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:

    1. mkdir -p ~/.local/packages
    2. package-manager config set global-prefix ~/.local/packages
    3. export 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:

    1. rm -rf ~/.local/packages/lib/node_modules/assistant-platform
    2. package-manager cache clean
    3. package-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:

    1. 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:

    1. 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:

    1. 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:

    1. 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:

    1. assistant-platform status
    2. assistant-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:

    1. 127.0.0.1:8080

    Never expose the admin port directly to the public internet. On your local machine, set up SSH port forwarding:

    1. 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:

    1. 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:

    1. ssh -N -L 18080:127.0.0.1:8080 user@server-address

    Then visit:

    1. 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

    1. Grant API keys minimal permissions; revoke and regenerate immediately if leaked.
    2. Restrict configuration file permissions to the owner only:
    1. chmod 600 ~/.config/assistant-platform/config.json
    1. Use SSH key authentication and disable unnecessary password logins.
    2. Bind the web admin service to localhost only, and prefer SSH port forwarding.
    3. Update the platform and its dependencies regularly, but back up your configuration first.
    4. Don’t log full request headers, keys, or sensitive conversation content.
    5. Review permissions for external plugins, automation scripts, and messaging channels.
    6. 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:

    1. Run the version command to confirm the platform starts.
    2. Check that the configuration file exists and is correctly formatted.
    3. Confirm the API URL is the base URL.
    4. Verify the model identifier is accurate.
    5. Check whether the key is expired, revoked, or incompletely copied.
    6. Use network test commands to confirm the server can reach the API.
    7. Check the HTTP status codes in the platform logs.
    8. 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.