Skip to content

Documentation

Everything from clone to uninstall.

Written against the agent as it actually ships. Every default and limit below was read out of the source, not remembered.

How it fits together

VPSGUI is two pieces. The console is a static React app - it holds no credentials and talks to nothing but the agent. The agent (vpsgui-agent) is a Node process on the host that does the actual work: reading /proc, shelling out, driving systemd and Docker, and touching the filesystem.

The agent binds to 127.0.0.1:46509 and is not reachable from the network. nginx serves the console and proxies /api/v1 to it, which means the only thing you expose is nginx.

request path
browser
  |
  |  https://vps.example.com          <- you expose this
  v
nginx  ---- static files ---->  /var/www/vpsgui/dist
  |
  |  proxy_pass /api/v1
  v
vpsgui-agent  127.0.0.1:46509       <- never exposed
  |
  v
the host: /proc, systemd, docker.sock, the filesystem

Warning

The agent token is root-equivalent. POST /api/v1/terminal/exec runs arbitrary commands as the agent user, so anyone with the token and a route to the agent owns the machine.

Requirements

  • Linux with Node.js 18 or newer, or Bun 1.2 or newer. Ubuntu, Debian, CentOS/RHEL, Alpine and Arch are all fine.
  • Root, or a user who can sudo. The installer writes to /opt, /var/www and the nginx config.
  • One of apt, dnf, apk or pacman for the package views to do anything.
  • systemd for service control, and a reachable Docker socket for the Docker views. Both are optional - those panels report unavailable without them.

Install

One script installs dependencies, builds the console, publishes it to /var/www/vpsgui/dist, installs the agent under pm2 and writes an nginx vhost.

bash
git clone https://github.com/NotGamerPratham/vpsgui.git && cd vpsgui && sudo ./run.sh

Set VPSGUI_SERVER_NAME first if the box already serves another site, otherwise the vhost claims default_server and collides with it.

bash
sudo VPSGUI_SERVER_NAME=vps.example.com ./run.sh

Re-running the script on an existing install is safe. It preserves the token and file roots already in agent.env rather than regenerating them, and it rolls the nginx config back if nginx -t fails.

The agent token

The installer generates a token and writes it to /opt/vpsgui/agent/agent.env, mode 0600. Every endpoint except /api/v1/health requires it.

bash
sudo cat /opt/vpsgui/agent/agent.env

Paste it into the console under Settings → Agent Token. It is kept in localStorage under vpsgui_auth_token and sent as an Authorization: Bearer header. Until you set it, every privileged call answers 401.

Important

The sign-in screen is a local profile gate, not authentication. VPSGUI ships no user database, no roles and no permissions - the token plus network reachability is the entire access model.

To rotate it, edit AGENT_TOKEN in agent.env and restart the agent. Every existing client is logged out immediately.

bash
sudo nano /opt/vpsgui/agent/agent.env
sudo pm2 restart vpsgui-agent

Put it behind TLS

The token travels in a request header. Over plain HTTP anything on the network path can read it, so terminate TLS before signing in from anywhere but the machine itself.

bash
sudo certbot --nginx -d vps.example.com

Then narrow who can reach it at all. A VPN or a firewall allowlist is doing more for you here than anything in the application.

bash
sudo ufw allow from 10.8.0.0/24 to any port 443 proto tcp
sudo ufw deny 443/tcp

Adding more hosts

Each machine runs its own agent with its own token, so revoking one host never touches the others. Download the installer, read it, then run it.

bash
curl -fsSLO https://raw.githubusercontent.com/NotGamerPratham/vpsgui/main/agent/install.sh
less install.sh
sudo bash install.sh

Important

Read the script before running it. Piping a remote URL straight into sudo bash executes whatever that URL returns at that moment, with no chance to look first.

Configuration

Everything lives in /opt/vpsgui/agent/agent.env. Restart the agent after editing. Exported environment variables win over the file, which wins over the defaults below.

VariableDefaultWhat it does
PORT46509Port the agent listens on.
AGENT_HOST127.0.0.1Bind address. Leave it on loopback unless you genuinely mean to expose the agent.
AGENT_TOKENgeneratedThe bearer token. Root-equivalent - treat it as a root password.
AGENT_FILE_ROOTS/Comma-separated roots the file manager may touch. Narrow this if you can.
AGENT_ENABLE_SHELL1Set to 0 to disable /terminal/exec entirely.
AGENT_ALLOW_SENSITIVE_FILES0Set to 1 to bypass the credential deny-list. There is rarely a good reason.
AGENT_ALLOWED_ORIGINSemptyExtra CORS origins, comma-separated. Same-origin already works.
AGENT_DEPLOY_ROOTS/var/www,/opt,/srv,/homeWhere deployment scanning looks for git checkouts.
AGENT_BACKUP_DIR/var/backups/vpsguiWhere backup archives are written.
AGENT_IPINFO_TOKENemptyOptional ipinfo.io token. Geolocation works without one (1k lookups/day); a free token raises it to 50k/month. Proxied server-side so it never reaches the browser.
AGENT_PROCESS_MANAGERpm2pm2 or systemd. The installer tears down the other one to avoid a port race.
VPSGUI_SERVER_NAME_nginx server_name for the generated vhost. Read by run.sh, not the agent.

Built-in limits

These are compiled into the agent rather than configurable, because each one exists to stop a single client exhausting the host.

LimitValueApplies to
Request body8 MB/files/write and every other JSON POST.
File read2 MBLarger files come back flagged truncated.
Command output4 MBCaptured stdout plus stderr from /terminal/exec.
Command timeout10 sA command still running is killed.
Package install timeout300 s/system/packages/install.
Failed auth attempts10Per client, before lockout.
Lockout duration5 minHow long that client gets 429.

Important

A file that came back truncated: true is also returned editable: false. Do not write that content back - it would truncate the real file on disk.

pm2 and systemd

pm2 supervises the agent by default. Set AGENT_PROCESS_MANAGER=systemd before installing if you would rather use a unit file; the installer removes whichever supervisor it is not using, so the two never race for port 46509.

pm2
sudo pm2 status
sudo pm2 logs vpsgui-agent --lines 100
sudo pm2 restart vpsgui-agent
systemd
sudo systemctl status vpsgui-agent
sudo journalctl -u vpsgui-agent -n 100 --no-pager
sudo systemctl restart vpsgui-agent

Running the agent on Bun

The installer sets up Node because that is what every distribution packages. The agent also runs unmodified on Bun, which starts faster and ships as a single binary.

bash
curl -fsSL https://bun.sh/install | bash
sudo bun /opt/vpsgui/agent/server.js

To make it permanent, point your supervisor at bun instead of node. Everything else - agent.env, the token, the file roots - is unchanged.

pm2
sudo pm2 delete vpsgui-agent
sudo pm2 start /opt/vpsgui/agent/server.js --name vpsgui-agent --interpreter bun
sudo pm2 save

Note

The two runtimes are not quite identical. fs.realpath returns a Windows drive root as F: on Bun and F:\ on Node, which the agent normalises before its path-confinement check - without that, Bun refused to list its own configured root. CI runs the full suite and the agent under both.

Command line

The same client ships as a vpsgui command. Install it from either registry - the two packages are the same CLI and share ~/.vpsgui/config.json, so it does not matter which one ends up on your PATH.

bash
npm i -g vpsgui
# or
pip install vpsgui

vpsgui login asks for the host and the agent token, checks them against the agent, and only then writes them to disk. The token is read with echo off, so it never reaches your shell history or a screen recording.

first run
$ vpsgui login vps.example.com
Agent token: ****************
Verifying https://vps.example.com/api/v1...

Signed in to vps-1
agent    1.6.0 on linux
profile  default
saved    /home/you/.vpsgui/config.json (mode 0600)
CommandWhat it does
vpsgui login [url]Save credentials for a host, after checking they work.
vpsgui whoamiShow the active profile and confirm the agent still accepts it.
vpsgui logoutForget this machine's copy of the token.
vpsgui statusCPU, memory, disk, and any failing checks.
vpsgui healthEvery health check, one per line. Exits non-zero on a red check.
vpsgui psDocker containers.
vpsgui ls [path]List a directory on the host.
vpsgui exec <command>Run a shell command. Exits non-zero when the command does.
vpsgui profilesList saved hosts.
vpsgui use <profile>Switch the default host.

Several hosts are just several profiles. Add --profile to any command to act on one without switching.

bash
vpsgui login vps-2.example.com --profile staging
vpsgui status --profile staging
vpsgui exec --profile staging 'systemctl restart nginx'

For CI, skip the login step entirely: VPSGUI_API_URL and VPSGUI_AGENT_TOKEN take precedence over any saved profile, so nothing is written to disk.

bash
export VPSGUI_API_URL=https://vps.example.com/api/v1
export VPSGUI_AGENT_TOKEN="$AGENT_TOKEN"
vpsgui health

Warning

Because the token is root-equivalent, ~/.vpsgui/config.json is written 0600 and vpsgui exec is full remote code execution. vpsgui logout only removes the copy on this machine - if the token leaked, rotate it on the host.

SDKs

The console is an ordinary client of the same API. Both SDKs cover every endpoint and read the token from the environment.

node
import { VpsguiClient } from 'vpsgui';

const client = new VpsguiClient({
  baseUrl: 'https://vps.example.com/api/v1',
  token: process.env.VPSGUI_AGENT_TOKEN!,
});

const telemetry = await client.system.telemetry();
console.log(telemetry.cpuPercent, telemetry.cpuCores);
python
import os
from vpsgui import VpsguiClient

with VpsguiClient(
    base_url="https://vps.example.com/api/v1",
    token=os.environ["VPSGUI_AGENT_TOKEN"],
) as client:
    for c in client.docker.list_containers():
        print(c["name"], c["state"])

Note

Fields the agent cannot determine come back null rather than guessed - smartHealth without smartctl, database size without credentials, city for an address ipinfo reports nothing for. Check before formatting.

Updating

Pull and re-run the deploy script. It rebuilds the console, republishes it, reinstalls the agent and reloads nginx, keeping your token and file roots.

bash
cd /path/to/vpsgui
git pull
sudo ./run.sh

Important

Run the script - do not just rebuild the console. The console lives in /var/www/vpsgui but the agent runs from /opt/vpsgui/agent, and only run.sh copies it there. A git pull plus npm run build leaves you with a new console calling routes the old agent has never heard of, which shows up as 404s on whole groups of endpoints.

Check what actually ended up on the host. The version the agent reports is the one that counts, not the one in the checkout.

bash
vpsgui whoami
grep AGENT_VERSION /opt/vpsgui/agent/server.js

Troubleshooting

SymptomCauseFix
401 on every callNo token, or the wrong one.Re-read agent.env and paste it under Settings → Agent Token.
429 on every callTen failed auth attempts locked this client out for five minutes.Fix the token, then wait it out. It clears on its own.
502 Bad Gatewaynginx is up but the agent is not.sudo pm2 status, then check sudo pm2 logs vpsgui-agent.
403 on POSTs onlyOrigin does not match what the agent expects.Confirm nginx forwards $http_host, or set AGENT_ALLOWED_ORIGINS.
404 on CSS and JSThe web root holds a stale build.Re-run sudo ./run.sh and hard-reload.
404 on /api/v1/auth/* or another whole route groupThe agent is older than the console. Rebuilding the frontend does not touch /opt/vpsgui/agent.Re-run sudo ./run.sh, which reinstalls the agent, then sudo pm2 restart vpsgui-agent.
"Path is outside the configured agent file roots"AGENT_FILE_ROOTS does not cover that path.Widen it in agent.env - deliberately, and restart.
Docker panels say unavailableNo Docker daemon, or the agent user cannot reach the socket.Confirm docker ps works as the agent user.

Health is the one route that needs no token, which makes it the fastest way to tell whether the agent is alive at all.

bash
curl -s http://127.0.0.1:46509/api/v1/health
curl -s https://vps.example.com/api/v1/health

Uninstalling

There is no uninstall script. Removing it by hand is four commands, and worth doing in this order so nginx never points at a missing root.

bash
sudo rm -f /etc/nginx/sites-enabled/vpsgui /etc/nginx/sites-available/vpsgui
sudo nginx -t && sudo systemctl reload nginx

sudo pm2 delete vpsgui-agent && sudo pm2 save
sudo rm -rf /opt/vpsgui /var/www/vpsgui

Note

Backups written to /var/backups/vpsgui are left alone on purpose. Delete them yourself once you are sure you want them gone.

Still stuck?

The long-form docs live in the repository, and anything not answered there is worth an issue - that is how entries end up on this page.