Install¶
All server backups from today live under /root/config-backups/ollama-2026-11-24/ on the VPS (root-only), see Backups. Sanitized copies of every file below are in config/.
Baseline found before changes¶
- Ubuntu 24.04.4, 37 days uptime, kernel 6.8.0-147, no swap, ~5.5 GiB RAM available, 6.1 GB of 96 GB disk used.
- ufw active: default deny incoming;
/tcp and 80,443/tcp from anywhere; 9100,9113/tcp on tailscale0 only. - unattended-upgrades installed and enabled (daily). 53 packages pending, reboot pending.
- sshd: cloud-init allowed root password login before the hardening drop-in was applied.
- Tailscale up. SSH sessions arrive over the public IP (not Tailscale), as root with a key.
OS updates and reboot¶
apt-get upgrade --with-new-pkgs(non-interactive, keep existing config files): 53 packages incl. systemd, tailscale, grafana, krb5, glib, apparmor, cloud-init, new kernels. Log:.../apt-upgrade.log.- Rebooted at ~2:23 AM ET into kernel 6.8.0-151-generic. All services came back; both sites returned 200.
- Ongoing: unattended-upgrades (security, daily). Reboots for kernel updates are manual: check
ls /var/run/reboot-required.
Swap¶
/swapfile4 GB (fallocate, mode 600), in/etc/fstabas/swapfile none swap sw 0 0./etc/sysctl.d/99-swappiness.conf:vm.swappiness=10(use RAM first, swap only under pressure).- Tweak:
sysctl -w vm.swappiness=Nand edit the file. Resize:swapoff /swapfile; fallocate -l 6G /swapfile; mkswap /swapfile; swapon /swapfile.
Ollama and qwen3:4b¶
- Installed with the official script (
curl -fsSL https://ollama.com/install.sh -o /root/ollama-install.sh, reviewed, then run). Creates userollama,/usr/local/bin/ollama, andollama.service(enabled). - Model:
qwen3:4bfrom the official Ollama library (Apache-2.0), 2.5 GB on disk, ~3.2 GB in RAM with a 4096 context, 100% CPU. About 11 tokens/s on this VPS; ~6 s to load. - Not an abliterated model: the official library does not host abliterated variants (those are community uploads with less clear provenance).
Drop-in: /etc/systemd/system/ollama.service.d/override.conf¶
| Setting | Value | Why |
|---|---|---|
OLLAMA_HOST |
127.0.0.1:11434 |
Loopback only. Ollama's API has no auth; never expose it. |
OLLAMA_MAX_LOADED_MODELS |
1 |
Only one model in RAM. |
OLLAMA_NUM_PARALLEL |
1 |
One request at a time (2 vCPU). |
OLLAMA_KEEP_ALIVE |
5m |
Unload after 5 idle minutes, returning ~3 GB RAM. |
OLLAMA_CONTEXT_LENGTH |
4096 |
Keeps KV cache small. |
MemoryHigh / MemoryMax |
4G / 5G |
cgroup caps so the model can't starve nginx, Postgres, Nautobot, Grafana. |
Tweak: edit the file, then systemctl daemon-reload && systemctl restart ollama. Check with systemctl show ollama -p Environment and ss -tlnp | grep 11434.
Using it¶
ollama list # installed models
ollama run qwen3:4b "Hello /no_think"
curl -s http://127.0.0.1:11434/api/generate \
-d '{"model":"qwen3:4b","prompt":"Reply with exactly: VPS OK /no_think","stream":false}'
ollama ps # what is loaded and until when
/no_think: qwen3 writes out its reasoning by default (slow on CPU). Ending the prompt with /no_think (or /think to force it) toggles that. The smoke test replied VPS OK /no_think at ~11 tok/s.
Remote use: only from the VPS itself, or via an SSH tunnel: ssh -L 11434:127.0.0.1:11434 root@<VPS_PUBLIC_IP>. To serve the tailnet instead, set OLLAMA_HOST=<VPS_TAILSCALE_IP>:11434 and add ufw allow in on tailscale0 to any port 11434 proto tcp; never a public allow.
Swap model: ollama pull <model> then ollama rm qwen3:4b. Stay at about 4B (or 7-8B Q4 at most) on 8 GB RAM.
SSH configuration¶
/etc/ssh/sshd_config.d/01-hardening.conf sorts before 50-cloud-init.conf; sshd uses the first value it reads. The sanitized file is in config/vps/etc/ssh/sshd_config.d/01-hardening.conf.
- Root can log in with a key only. Confirm the current password-authentication values in that drop-in rather than assuming password login is off.
- Change: edit the drop-in, then
sshd -t && systemctl reload ssh, and test a new session before closing the current one. - Port
<SSH_PORT>stays publicly reachable (admin access currently arrives over the public IP). See security.md.
SSH login alerts (ntfy)¶
See security.md#ssh-login-alerts-ntfy. Files: /etc/pam.d/sshd (last line), /usr/local/sbin/ssh-login-ntfy.sh, /etc/goc-alerting/ntfy.env (0600, same topic as linux-01's Alertmanager bridge), log /var/log/ssh-login-ntfy.log.
fail2ban¶
Package fail2ban 1.0.2-3ubuntu0.1, config /etc/fail2ban/jail.local. Details in security.md#fail2ban.
SSH geo-block¶
Packages ipset. Files: /usr/local/sbin/geoip-ssh-sets.sh, geoip-ssh-sets.service, geoip-ssh-update.service + .timer, cache /var/lib/geoip-ssh/zone4.zone and zone6.zone, rules in /etc/ufw/before.rules and before6.rules, revert /root/geo-ssh-revert.sh. Details in security.md#ssh-geo-block.
Accounts¶
jconover (uid 1000, created 2026-08-11, password locked, never logged in per lastlog/wtmp/auth logs, had NOPASSWD:ALL sudo) was archived to .../followup/jconover-home.tgz and removed with userdel -r; /etc/sudoers.d/jconover deleted (copy kept).
Monitoring (linux-01 Prometheus)¶
Scrape jobs on linux-01 (unchanged): vps-node -> <VPS_TAILSCALE_IP>:9100, vps-nginx -> <VPS_TAILSCALE_IP>:9113 (both label host="goc-vps", instance = target address), vps-nautobot (local exporter, instance="cbgoc-cloud.top").
node_exporter on the VPS¶
/etc/default/prometheus-node-exporter ARGS add:
--collector.systemd --collector.systemd.unit-include=(ollama|prompts-chat|fail2ban|ssh|geoip-ssh-sets|geoip-ssh-update)[.]service|geoip-ssh-update[.]timer
Listens on 127.0.0.1:9100 and <VPS_TAILSCALE_IP>:9100 only (no change). The textfile collector reads /var/lib/prometheus/node-exporter/ (Debian default).
Security metrics (textfile collector)¶
/usr/local/sbin/goc-vps-sec-metrics.sh, run every 2 min by goc-vps-sec-metrics.timer, writes goc_vps_security.prom atomically. No IPs or usernames exported.
| Metric | Labels | Meaning |
|---|---|---|
goc_fail2ban_up |
1 if fail2ban answered | |
goc_fail2ban_banned_current |
jail |
IPs banned now |
goc_fail2ban_banned_total |
jail |
bans since fail2ban start |
goc_fail2ban_failed_current / _failed_total |
jail |
failures tracked now / since start |
goc_ssh_geo_drop_packets_total / _bytes_total |
family (ipv4/ipv6) |
SSH packets dropped by geo-block (reset on ufw reload) |
goc_ssh_geo_rule_present |
family |
1 if the geo DROP rule is loaded |
goc_ssh_geo_ipset_entries |
set |
size of geo-ssh-allow4/6 |
goc_ssh_login_alerts_total |
SSH login alerts sent (log lines) | |
goc_ssh_login_alerts_failed_total |
alerts that did not get HTTP 200 | |
goc_ssh_login_alerts_last_timestamp_seconds |
time of last alert | |
goc_vps_sec_metrics_last_run_timestamp_seconds |
exporter heartbeat |
Alert rules: /etc/prometheus/rules/vps-ollama.yml on linux-01¶
| Alert | Expression (summary) | For | Labels |
|---|---|---|---|
VPSOllamaDown |
ollama.service active != 1 | 5m | severity: warning |
VPSOllamaMetricMissing |
ollama.service state absent | 15m | severity: warning |
VPSSwapHeavy |
VPS swap > 50% used | 15m | severity: warning |
VPSPromptsChatDown |
prompts-chat.service active != 1 | 5m | severity: warning |
VPSPromptsChatMetricMissing |
prompts-chat.service state absent | 15m | severity: warning |
Routed by the existing Alertmanager -> ntfy bridge. Change: edit, promtool check rules <file>, systemctl reload prometheus.
Prompts library (prompts.chat)¶
- Why this architecture: Upstream
willyd61/awesome-chatgpt-prompts(prompts.chat) is a Next.js + Prisma + PostgreSQL web application. Running a full Node.js build/runtime plus a separate database on an 8 GB / 2 vCPU VPS alongsideqwen3:4b(MemoryMax=5G), Nautobot, Postgres, Redis, Grafana, and nginx would starve RAM. Instead, a zero-dependency Python 3 stdlib server (/opt/prompts-chat/app.py) loadsprompts.csvdirectly and proxies chat requests to local Ollama. - Files and paths:
/opt/prompts-chat/app.py— single-page web UI + JSON API (/,/healthz,/api/prompts,/api/prompts/<id>,/api/models,/api/chat,/api/run)./opt/prompts-chat/data/prompts.csv— 3,157 prompts loaded into memory at startup./etc/default/prompts-chat—PROMPTS_HOST=127.0.0.1,PROMPTS_PORT=8090,PROMPTS_CSV=/opt/prompts-chat/data/prompts.csv,OLLAMA_URL=http://127.0.0.1:11434,DEFAULT_MODEL=qwen3:4b,NUM_CTX=8192,MAX_SYSTEM_CHARS=16000,OLLAMA_TIMEOUT=600,NO_THINK_TAG=/no_think./etc/systemd/system/prompts-chat.service— runs as dedicated user/grouppromptschat; cgroup limitsMemoryHigh=200M,MemoryMax=256M,CPUQuota=50%,TasksMax=64; network locked to loopback (IPAddressDeny=any,IPAddressAllow=localhost)./usr/local/sbin/prompts-chat-update(sanitized copy),prompts-chat-update.service,prompts-chat-update.timer— weekly refresh ofprompts.csvfrom GitHub (Sun 04:30:00+ up to 30m random delay,Persistent=true). The script validates the CSV, keepsprompts.csv.prev, and supports--rollback./usr/local/bin/prompts-ask(sanitized copy) — local CLI wrapper on the VPS (--search,--show, or run a prompt).- Reachability (tailnet-only):
- Published with
tailscale serve --bg --http=8090 http://127.0.0.1:8090, which proxieshttp://goc-vps:8090andhttp://goc-vps.<TAILNET>.ts.net:8090(tailnet only) tohttp://127.0.0.1:8090. Seeconfig/vps/usr/local/tailscale-serve.md. - On hosts where local DNS/search domain overrides
goc-vps(e.g.,linux-01wildcard*.cbgoc-hamlet.top), reach it viacurl -H "Host: goc-vps:8090" http://<VPS_TAILSCALE_IP>:8090/healthz(orcurl --resolve goc-vps:8090:<VPS_TAILSCALE_IP> http://goc-vps:8090/), or via SSH tunnelssh -L 8090:127.0.0.1:8090 root@<VPS_PUBLIC_IP>. - RAM impact:
- Before (
free-before.txt): 2,092 MiB used, 4,436 MiB free, 5,848 MiB available, 0 MiB swap used. - Peak after test chat with
qwen3:4bloaded (free-after.txt): 6,303 MiB used, 187 MiB free, 1,637 MiB available, 1,548 MiB swap used. - Steady-state idle (after
OLLAMA_KEEP_ALIVE=5munloadsqwen3:4b): ~2.7 GiB used, ~5.1 GiB available, ~9.2 MiB swap used;prompts-chat.serviceitself uses ~47.3 MiB RSS (peak 47.8 MiB). - Monitoring:
prompts-chatadded toprometheus-node-exporter's--collector.systemd.unit-includelist;VPSPromptsChatDownandVPSPromptsChatMetricMissingadded to/etc/prometheus/rules/vps-ollama.ymlonlinux-01.
Backups¶
VPS, /root/config-backups/ollama-2026-11-24/ (root 700):
| Path | Contents |
|---|---|
./ |
ssh/, ufw/, fstab, sysctl.d/, prometheus-node-exporter (+ .pre-systemd), sshd-T-before.txt, ufw-before.txt, ufw-after.txt, apt list + apt-upgrade.log, ollama-install.log |
followup/ |
ssh/, pam.d/ (before alert hook), jconover-home.tgz, jconover passwd/group entries, sudoers.d copy, passwd/group/shadow/gshadow copies, ufw pre/post reboot |
fail2ban-geo/ |
ufw/ (original before.rules), iptables/ip6tables/nft dumps before and after, ufw-before.txt/ufw-after.txt, after/ (new before.rules, jail.local), apt log |
monitoring-ext/ |
node-exporter defaults before the systemd-list extension |
VPS, /root/config-backups/prompts-2026-11-24/ (root 700): app.py.v1, prompts-chat.default.v1, prometheus-node-exporter.default.bak, tailscale-serve-before.json ({}), ufw-before.txt, free-before.txt, free-after.txt.
linux-01, /root/config-backups/ollama-2026-11-24/: prometheus.yml, rules/ (before vps-ollama.yml was added).