Deploy an AI Coding Assistant on Ubuntu 24.04 and Connect It to an LLM Service

    This guide walks through deploying an AI coding assistant on an Ubuntu 24.04 server, connecting it to an external large language model (LLM) API, and setting up secure remote access. You will learn how to install a controlled Node.js runtime with a version manager, globally install the assistant and troubleshoot common directory errors, configure a custom provider through the interactive wizard or a YAML file, and use an SSH tunnel to reach the web interface without exposing a public port. The workflow applies to most LLM platforms that expose a standard API, including Baidu AI Cloud, which follows the same key-endpoint-model setup logic. It also covers key file permissions, firewall rules, and key rotation practices.

    Deploy an AI Coding Assistant on Ubuntu 24.04 and Connect It to an LLM Service

    Why Deploy AI Coding Tools on a Server

    As large language models mature, more developers want to run intelligent coding assistants on remote servers for real-time help with project development, code review, and automated script generation. Running the AI tool on a cloud server instead of locally offers three main advantages: compute and environment isolation that avoids dependency conflicts on your local machine, a shared configuration for the whole team, and secure remote access over an encrypted channel.

    This article covers three core steps: installing the coding assistant on an Ubuntu 24.04 server, configuring an external LLM service, and establishing a secure access channel. The approach relies on common industry practices and works with most LLM platforms that provide a standard interface. If you want to use AI capabilities from Baidu AI Cloud, you can adapt the same general integration logic described here.

    Step 1: Prepare the Environment and Install the Runtime

    Any Node.js-based AI tool needs a stable runtime with a controlled version. The Node.js version in the default Ubuntu 24.04 repositories is often outdated, and installing it directly through the package manager can lead to dependency incompatibilities later. A version manager is recommended so you can pin the runtime version precisely.

    1.1 Install the Runtime with a Version Manager

    A version manager installs different runtime versions under your user directory and switches between them by modifying environment variables, which keeps the system-wide environment clean.

    1. # Download and run the version manager install script
    2. curl -o- https://<version-manager-official-url>/install.sh | bash
    3. # Reload the shell configuration to apply environment variables
    4. source ~/.bashrc
    5. # Install the LTS version (version 22 in this example)
    6. versionmanager install 22
    7. versionmanager alias default 22
    8. # Verify the installation
    9. node --version
    10. # Expected output: v22.x.x

    1.2 Prerequisites

    • An Ubuntu 24.04 server; creating a non-root user for the work reduces the risk of accidental damage.
    • An API key from the target LLM platform, usually created in the platform’s console after registration and typically a string starting with sk-.
    • A local terminal with SSH support; any operating system works.

    Step 2: Install the AI Coding Assistant

    Once the runtime is ready, install the tool globally through the package manager. A global install makes the command callable from any path, which suits a system-level tool.

    1. # Install the latest version globally
    2. npm install -g <assistant-package-name>@latest

    2.1 Troubleshooting Common Installation Issues

    The most frequent error during installation is a non-empty directory error, usually caused by an interrupted previous install that left an incomplete module directory behind. The fix is to remove the leftovers completely and rebuild the cache:

    1. # Remove the leftover module directory
    2. rm -rf ~/.npm-global/lib/node_modules/<package-name>
    3. # Force a clean of the package manager cache
    4. npm cache clean --force
    5. # Run the installation again
    6. npm install -g <assistant-package-name>@latest

    Deprecation warnings in the install log are normal as the ecosystem evolves and can be ignored as long as the command works afterward.

    2.2 Verify the Installation

    1. # Check the version
    2. <assistant-command> --version
    3. # Expected output: a version string such as 2026.x.x

    Step 3: Connect an External LLM Service

    The coding assistant does not include a model itself; it acts as a shell that needs an external LLM API to function. This step is the core of the deployment.

    3.1 Interactive Configuration Wizard

    Most tools of this kind provide an interactive configuration command that prompts you through the parameters:

    1. <assistant-command> config

    Follow the prompts to complete these choices:

    1. Select the option to add a custom provider.
    2. Enter a custom provider identifier, for example custom-llm.
    3. Enter the API base URL, which should follow the v4 or corresponding version endpoint path given in the target platform’s documentation; do not omit the protocol prefix.
    4. Paste your API key.
    5. Specify the model name using the identifier of the model you have access to.

    3.2 Manual Configuration File Editing (Advanced)

    If the interactive wizard cannot run because of terminal limitations, edit the configuration file in your user directory directly. The file typically uses YAML or JSON, with core fields for the provider name, endpoint, key, and model name.

    1. providers:
    2. custom-llm:
    3. baseURL: "https://<your-model-endpoint>/v1"
    4. apiKey: "sk-<your-key>"
    5. models:
    6. - id: "<target-model-id>"

    Security note: The key is a sensitive credential. Make sure the configuration file has 600 permissions so only the owner can read and write it, preventing leaks.

    Step 4: Access the Web Interface Securely Through an SSH Tunnel

    After deployment, the tool usually starts a local web service port. Exposing that port directly to the public internet risks scan-based attacks, so use SSH port forwarding to create an encrypted tunnel.

    4.1 Set Up Local Forwarding

    Run this on your local machine:

    1. ssh -L 8080:127.0.0.1:8080 <user>@<server-ip>

    This maps your local port 8080 to port 8080 on the server, where the service listens on the loopback address. You can then open http://127.0.0.1:8080 in your local browser, and all traffic travels through the encrypted SSH connection.

    4.2 Harden the Setup Further

    • Allow only the SSH port in the server firewall and stop the web service port from listening on the public network.
    • Use key pairs instead of password login, and disable password authentication.
    • If multiple team members need access, combine a reverse proxy with an authentication layer.

    Summary and Best Practices

    This article laid out a complete path: build a clean runtime with a version manager, install the coding assistant globally and handle the typical leftover-directory error, connect an external LLM API through the wizard or a manual configuration file, and use an SSH encrypted tunnel for access with zero exposure.

    Three points matter in production use. First, update the tool and runtime regularly to pick up security patches. Second, rotate API keys and monitor usage to avoid abnormal consumption. Third, manage configuration files and keys with a secrets management approach instead of committing them in plaintext to a code repository. If you use model services from Baidu AI Cloud, the same three-step method applies: get the key, enter the endpoint, and specify the model identifier.