Self-Hosted AI Assistant on Linux: Deploy, Add a Custom Model, and Access the Console Safely
This guide walks through installing a self-hosted AI assistant CLI on a Linux server, connecting a custom model provider, verifying the API path, reaching the web console over SSH local forwarding, and covering typical install, PATH, auth, and systemd issues.
1. Background and goals
Teams that adopt large language models often hit two practical constraints: calling public APIs leaves data paths and access control outside your environment, and providers differ enough that there is no single place to manage sessions and credentials. A self-hosted AI assistant platform addresses this by combining model adapters, conversation management, a web console, and multi-channel messaging (web and common IM tools) in a service you operate. You can swap the underlying model and keep audit and permission policies in one place.
This article is an end-to-end practice:
- Install and run the assistant platform CLI on a Linux server.
- Add a custom model provider in the setup wizard and connect an external LLM API.
- Reach the web console from a local browser using SSH port forwarding.
- Troubleshoot failed installs, leftover packages, and connection problems.
2. Environment
2.1 Server
- A remotely reachable Linux host on a current mainstream distribution, with kernel and system libraries kept up to date.
- Root or sudo. In production, use a regular user and sudo rather than running the service as root long term.
- Outbound network access to download packages and call the model API.
2.2 Local machine
- Windows, macOS, or Linux with SSH to the server.
- Prefer SSH key login to reduce password exposure and to simplify port forwarding.
2.3 Runtime
These platforms typically run on Node.js. Check versions:
node -vnpm -v
If the commands are missing or too old, install the current LTS via the OS package manager or the official installer. LTS is a better fit for production compatibility and security patches. Verify versions again after install.
3. Install the assistant CLI
3.1 Global install
Install the CLI globally with the Node package manager (use the package name from official docs; shown here as a placeholder):
npm install -g <assistant-cli>@latest
Verify:
<assistant-cli> --version
You should see a version such as 2026.3.2. That means the global binary is on PATH.
3.2 Common install issues
ENOTEMPTY
This usually means a previous install left a non-empty directory in the global modules path. Cleanup:
# 1. Remove leftover global module dir (path is in the error)rm -rf <global node_modules path>/<assistant-cli># 2. Clear the package manager cachenpm cache clean --force# 3. Reinstallnpm install -g <assistant-cli>@latest
deprecated warnings
These are common in the dependency tree and usually do not break the tool. If you also see EPERM/EACCES, the global prefix is not writable by your user. Avoid forcing sudo for global npm installs; point the prefix at a user-writable directory and add its bin directory to PATH.
command not found
If install succeeded but <assistant-cli> is missing, the global bin directory is not on PATH. Run npm bin -g (or npm prefix -g), then append that path in your shell profile.
4. Configure a custom model provider
Run the interactive wizard:
<assistant-cli> config
Typical steps:
- Add a custom provider — choose an option such as “Add custom provider,” not a built-in list entry.
- Name it — a clear id such as
custom-llm. - API base URL — the HTTPS base URL from the provider’s API documentation, often including a version path.
- API key — the key from the provider console. It is usually shown in full only once; store it safely and rotate it if leaked.
- Model name — the exact model id from the docs, including case and version.
- Save — the wizard writes a local config file.
Practice notes:
- Key safety: treat the API key as a secret; restrict the config file (for example
chmod 600) and never commit it. - Matching trio: base URL, key, and model name must come from the same provider; mixing them causes auth failures or “model not found.”
- Start small: first verify with a lighter, cheaper model, then switch to a stronger one.
5. Verify model connectivity
Minimal check from the CLI:
# Interactive mode<assistant-cli># Or send a test message if the tool supports it<assistant-cli> chat --message "Hello, please introduce yourself"
A model reply means the server-to-provider path works. Auth errors: extra spaces or expired keys. URL errors: compare the base URL with the docs. Timeouts: outbound firewall and security-group rules.
6. Access the web console with SSH local forwarding
Do not expose the console on the public internet. SSH local forwarding needs no extra software: traffic stays in the encrypted SSH tunnel, and the web port need not be open on the host.
On your local machine:
ssh -N -L 8080:127.0.0.1:8080 <user>@<server-ip>
-L 8080:127.0.0.1:8080forwards local 8080 to the server’s 127.0.0.1:8080.-Ncreates the tunnel without a remote shell.- Bind the service to
127.0.0.1so only loopback can reach it.
Open:
http://127.0.0.1:8080
On first visit, create the admin account and use a strong password or key-based login.
Connection issues
- Page does not load: confirm the assistant is running and the listen port (
ss -lntp | grep <port>), and that the tunnel command has no errors. - Tunnel up, no response: the forward target must be
127.0.0.1, not0.0.0.0or a public IP. - Port in use: use another local port, for example
-L 18080:127.0.0.1:8080, and browse127.0.0.1:18080.
7. systemd and operations
To start after reboot, a systemd unit (example):
# /etc/systemd/system/assistant.service[Unit]Description=Self-hosted AI AssistantAfter=network-online.target[Service]User=<run-as-user>ExecStart=/usr/bin/env <assistant-cli> startRestart=on-failureRestartSec=5[Install]WantedBy=multi-user.target
Enable and start:
sudo systemctl daemon-reloadsudo systemctl enable --now assistant.servicesudo systemctl status assistant.service
Operations:
- Logs:
journalctl -u assistant -f; start and auth lines first when debugging. - Updates: read official release notes, upgrade with the same global install command, and clean leftover dirs on ENOTEMPTY as above.
- Backups: back up config and conversation data directories.
- Network: open SSH tunnels only when needed; keep the service on loopback; firewall should allow SSH only.
8. Summary
This walkthrough covers deploying a self-hosted AI assistant on Linux and attaching a custom LLM provider: Node.js and global CLI install (including leftover cleanup), wizard-based key handling, encrypted console access via SSH local forwarding, and systemd. Keep credentials off the public network (loopback plus tunnel), keep base URL, key, and model name aligned, and clean before reinstalling if packages are left behind. That yields a service you can audit and whose models you can replace.
