Zero APIs, Full Autonomy:
Engineering a Self-Hosted AI Pentesting Lab with PentAGI
Engineering a Self-Hosted AI Pentesting Lab with PentAGI
To evaluate autonomous AI penetration testing in an isolated home lab using Ollama, two separate components are required: an agentic orchestration framework (which handles planning, tool execution, and state tracking) and a local LLM with removed refusal guardrails (so the model doesn’t stall out on benign security assessments of lab targets).
Ollama-Compatible Open-Source Agentic Frameworks Considered
These frameworks connect an LLM to standard security toolchains (like Nmap, SQLmap, or terminal environments) inside isolated containers so security researchers can observe how autonomous workflows operate.
| Framework | Architecture & Capabilities | Ollama Integration | Best For |
|---|---|---|---|
| PentAGI | Multi-agent system (Planner, Researcher, Executor, Reporter) running 20+ Kali tools inside isolated Docker sandboxes with vector memory and loop detection. | Native support via LiteLLM / local OpenAI-compatible endpoints. | Observing end-to-end autonomous task decomposition and multi-agent coordination. |
| CAI (Cybersecurity AI) | Modular Python framework (cai-framework) using pre-defined attack/defense “patterns,” OpenTelemetry tracing, and local CLI/Web UI execution. | Built-in support for local Ollama models (e.g., Qwen, Llama, Mistral variants). | Tracing exact agent decision trees, telemetry, and tool-calling patterns. |
| PentestGPT (v1.0+) | Agentic pipeline divided into Recon, Exploit/Vuln ID, and Walkthrough/Report stages with session persistence inside Docker. | Supported via local LLM routing (ollama.env pointing to port 11434). | Benchmarking structured, phased testing against intentional vulnerable targets (like DVWA or Juice Shop). |
| Xalgorix | Self-hosted Go/TypeScript engine that runs a 22-phase assessment methodology followed by an independent verification agent to filter false positives. | Fully local/air-gapped operation supported via Ollama. | Studying how automated verification reduces alert fatigue compared to traditional scanners. |
Local LLMs Without Refusal Guardrails
Standard open-weights models often refuse security-related prompts—even when analyzing lab infrastructure—because of safety fine-tuning. For authorized research, security engineers typically use “abliterated” models (where the specific activation direction responsible for refusals has been surgically removed from the weights without degrading reasoning) or uncensored fine-tunes.
- Huihui-Qwen3.5-27B-abliterated / Qwen3.8-27B-OBLITERATED: Strong general-purpose reasoning and tool-calling accuracy with refusal vectors removed. Ideal if you have ~24GB+ of VRAM (quantized) and need reliable JSON/function-calling output for agent loops.
- Gemma-4-26B-A4B-it-uncensored: A Mixture-of-Experts (MoE) model with ~4B active parameters per token, offering very fast inference speeds on consumer GPUs while maintaining low refusal rates (~0.7%).
Dolphin-Llama-3 (8B) / Dolphin-Mistral: Lightweight uncensored fine-tunes. While older and less capable at complex multi-step tool orchestration than 27B+ models, they run easily on 8GB–12GB VRAM setups for basic command generation and log analysis.
Side Note: Smaller 7B–8B local models frequently struggle with strict tool-calling schemas and get stuck in infinite loops; frameworks with built-in loop detection like PentAGI or models in the 24B–32B range perform significantly better.
Engineering Benefits
- Velocity & Persistence: Traditional automated scanners run static rule sets once. Agentic frameworks dynamically pivot based on terminal output—chaining reconnaissance findings into targeted enumeration 24/7 without human fatigue.
- Reduction of the Skill Floor: While local models still struggle with novel zero-day discovery, they excel at gluing together existing open-source tools, parsing messy output, and exploiting known misconfigurations or unpatched CVEs at scale.
- Air-Gapped & Untraceable Operation: Running uncensored models locally via Ollama eliminates reliance on commercial APIs, meaning defenders cannot rely on cloud provider moderation or API telemetry to detect threat actors developing or automating workflows.
- Telemetry & Behavioral Signatures: Testing these agents in controlled environments allows security researchers to capture distinct network and process signatures—such as rapid, sequential tool execution, repetitive enumeration bursts, and non-human timing intervals—which can be translated into SIEM detection rules.
Best Practice: Lab Isolation
Network Segmentation: Place both the agent containers and target VMs (e.g., OWASP Juice Shop, Metasploitable, or Active Directory lab ranges) on an isolated, host-only virtual network with no outbound internet access except where explicitly required.
Telemetry Review: Check framework defaults before running tests—tools like PentestGPT include opt-out anonymous telemetry (e.g., Langfuse session metadata) that should be disabled via environment flags during offline lab evaluations.
Architecture Comparison for My Homelab
| Factor | PentAGI | PentestGPT |
|---|---|---|
| Execution Topology | Client/Server Web UI (:8443): Runs entirely on your Arch host alongside Ollama; you drive it from a browser on your Kali laptop. | CLI-Driven: Typically installed directly on the client (your Kali laptop) and pointed remotely at your Arch server’s Ollama API (OLLAMA_BASE_URL). |
| Autonomy Model | Multi-agent sandbox: Spawns isolated Docker worker containers with pre-installed tools and executes commands autonomously with loop detection. | Interactive copilot / phased loop: Newer builds support autonomous target execution, while classic workflows act as a step-by-step advisor where you run commands on Kali and paste output back. |
| 24 GB VRAM & Context | Built-in provider tuning: Ships with explicit YAML profiles for Qwen models and requires expanding Ollama’s context window (num_ctx) to handle multi-agent memory. | Lightweight prompting: Consumes less context per turn, making it easier on VRAM, though it lacks PentAGI’s vector database (pgvector) and graph memory (Neo4j). |
| Observability for Write-Ups | High: Includes built-in diagnostics (ctester, etester), full execution trees, and structured reporting out of the box. | Moderate: Logs CLI session histories and todo trees, which is great for comparing human-in-the-loop vs. autonomous behavior. |
Why PentAGI Fits My Hardware & Workflow Best
Zero-Overhead Kali Client: There is no need to install Python dependencies or manage Docker containers on the security researchers pentesting laptop. Simply deploy PentAGI on your Arch box, set
PENTAGI_LISTEN_IP=0.0.0.0(or bind it to a WireGuard/Tailscale interface), and access the web console from the laptop web browser.VRAM & Context Window Management (Crucial for 24 GB): A quantized
Qwen3.8-27Bmodel will occupy roughly 16–18 GB of VRAM, leaving 6–8 GB for the KV cache. PentAGI’s documentation notes that multi-agent flows default to high context sizes (up to 64K–110K tokens). On a 24 GB card, a 110K context window will spill into system RAM and tank your tokens-per-second. You will want to create a custom Ollama Modelfile from yourqwen3.8-27B-Obliteratedweights cappingPARAMETER num_ctx 32768(or16384if memory pressure spikes) and enable Ollama’sOLLAMA_FLASH_ATTENTION=1andOLLAMA_KV_CACHE_TYPE=q8_0environment variables on Arch.Built-in Tool-Calling Diagnostics: Uncensored/abliterated models sometimes break structured JSON tool-calling schemas. PentAGI includes a CLI utility (
ctester) inside its container specifically to verify that your local model properly handles function calls before you kick off a full lab run.Local Embeddings Support: PentAGI uses semantic memory to avoid repeating failed paths. You can point
EMBEDDING_PROVIDER=ollamato a tiny embedding model (likenomic-embed-text, ~275 MB VRAM) on the same Arch host so the entire stack remains 100% air-gapped.
High-Level Deployment Flow (Arch Host)
Tune Ollama for 24 GB VRAM and Remote Access
- Ensure Ollama’s systemd service has
OLLAMA_FLASH_ATTENTION=1andOLLAMA_KV_CACHE_TYPE=q8_0configured to minimize KV cache VRAM usage. - Create a custom Modelfile derived from
qwen3.8-27B-ObliteratedwithPARAMETER num_ctx 32768andPARAMETER temperature 0.3so PentAGI’s agent prompts aren’t truncated at Ollama’s default 2K–4K context limit. - Verificaion: Run
ollama show <your-custom-model-name>on the Arch host and confirmnum_ctx 32768is listed under parameters.
- Ensure Ollama’s systemd service has
Deploy PentAGI via Docker Compose
- Clone the PentAGI repository or use their terminal installer to generate the .
envfile. - Configure OLLAMA_SERVER_URL to point to your host’s Docker bridge IP (e.g., http://172.17.0.1:11434).
- Set
OLLAMA_SERVER_MODELto your custom Qwen model. - Configure
EMBEDDING_PROVIDER=ollamawith a lightweight embedding mode. - Set
PENTAGI_LISTEN_IP=0.0.0.0(ideally restricted viaufw/nftablesto your Pentesting laptop’s IP). -Verification: Rundocker compose psand confirm thepentagi,pgvector, andneo4jcontainers are healthy.
- Clone the PentAGI repository or use their terminal installer to generate the .
Validate tool-calling
- Before connecting from Kali, run PentAGI’s built-in verification binaries (
docker exec -it pentagi /opt/pentagi/bin/ctester -verboseandetester test -verbose) to confirm that your abliterated Qwen model adheres to function-calling schemas without syntax errors. -Verification: Both utilities return passing checks with valid JSON tool-call parsing and embedding generation.
- Before connecting from Kali, run PentAGI’s built-in verification binaries (
Access from the Kali console
- Navigate to
https://<arch-host-ip>:8443from your Kali browser, log in with the configured admin credentials, and scope your first test exclusively to an isolated target container or VM on your lab subnet. -Verification: The PentAGI web dashboard loads over HTTPS and displays your local Ollama model as active in the provider settings.
- Navigate to
Warning: Network Exposure
Because your Ollama instance is listening on all interfaces (0.0.0.0) and runs an uncensored model without authentication by default, restrict port 11434 and PentAGI’s port 8443 at the host firewall level so the Pentesting laptop and the local Docker bridge can access them.
Note: To compare a pure CLI workflow directly from the Pentesting laptop later, install PentestGPT and point its OLLAMA_BASE_URL at http://<arch-host-ip>:11434 using the exact same model.
Step by Step Configuration
Step 1: Tune Ollama for 24 GB VRAM
By default, Ollama uses a small context window (2K–4K tokens), which will truncate PentAGI’s multi-agent prompts, while setting it too high (like PentAGI’s 110K maximum) will overflow 24 GB of VRAM into system RAM. Enable Flash Attention and quantized KV caching, then create a model variant capped at 32K context.
Edit the Ollama systemd service override:
1
sudo systemctl edit ollama.serviceAdd the following lines above the
# Lines below this comment will be discardedmarker (keeping your existingOLLAMA_HOST=0.0.0.0variable):[Service] Environment="OLLAMA_HOST=0.0.0.0" Environment="OLLAMA_FLASH_ATTENTION=1" Environment="OLLAMA_KV_CACHE_TYPE=q8_0"Reload and restart Ollama:
1 2
sudo systemctl daemon-reload sudo systemctl restart ollama
Pull a lightweight embedding model for PentAGI’s vector memory (~275 MB VRAM):
1
ollama pull nomic-embed-text
Check the exact local model tag with
ollama list, then create a Modelfile (~/Modelfile.pentagi) to lock in a 32K context window and low temperature for reliable tool-calling:1 2 3 4 5 6 7
cat << 'EOF' > ~/Modelfile.pentagi FROM qwen3.8-27B-Obliterated PARAMETER num_ctx 32768 PARAMETER temperature 0.3 PARAMETER top_p 0.8 PARAMETER repeat_penalty 1.1 EOF
NOTE: Replace
qwen3.8-27B-Obliteratedon theFROMline with the exact tag shown inollama list.Build the custom model variant and verify its parameters:
1 2
ollama create qwen38-pentagi -f ~/Modelfile.pentagi ollama show qwen38-pentagi
Step 2: Prepare the PentAGI Workspace
Ensure Docker and the Docker Compose plugin are installed and running (sudo systemctl enable --now docker), and that your user is in the docker group.
Create a working directory and download the environment template and compose file:
1 2 3
mkdir -p ~/pentagi && cd ~/pentagi curl -fo .env https://raw.githubusercontent.com/vxcontrol/pentagi/main/.env.example curl -O https://raw.githubusercontent.com/vxcontrol/pentagi/main/docker-compose.yml
Create the empty provider placeholder files required by
docker-compose.ymlmounts:1
touch example.custom.provider.yml example.ollama.provider.yml example.bedrock.provider.ymlGenerate random secrets for your session salt and database passwords inside
.env1 2 3
sed -i "s/^COOKIE_SIGNING_SALT=.*/COOKIE_SIGNING_SALT=$(openssl rand -hex 32)/" .env sed -i "s/^PENTAGI_POSTGRES_PASSWORD=.*/PENTAGI_POSTGRES_PASSWORD=$(openssl rand -hex 16)/" .env sed -i "s/^NEO4J_PASSWORD=.*/NEO4J_PASSWORD=$(openssl rand -hex 16)/" .env
Step 3: Configure .env for Local Ollama and Remote Kali Access
Find your Arch system’s LAN IP address (ip -br a) and Docker bridge IP (ip -br a show docker0 — typically 172.17.0.1).
Open .env in your editor (nvim .env or nano .env) and update the following variables (replace <ARCH_LAN_IP> with your Arch box’s actual IP address):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Network & Web UI Access (Allow connection from Kali laptop)
PUBLIC_URL=https://<ARCH_LAN_IP>:8443
CORS_ORIGINS=https://localhost:8443,https://<ARCH_LAN_IP>:8443
PENTAGI_LISTEN_IP=0.0.0.0
PENTAGI_LISTEN_PORT=8443
# Local Ollama LLM Configuration (Reached via Docker bridge)
OLLAMA_SERVER_URL=http://172.17.0.1:11434
OLLAMA_SERVER_MODEL=qwen38-pentagi
# Local Embeddings Configuration
EMBEDDING_PROVIDER=ollama
EMBEDDING_URL=http://172.17.0.1:11434
EMBEDDING_MODEL=nomic-embed-text
# Optional: Disable external search or telemetry if running fully air-gapped
DUCKDUCKGO_ENABLED=false
SPLOITUS_ENABLED=false
Note: If you have ufw or firewalld active on Arch, allow port 11434/tcp from the 172.17.0.0/16 Docker subnet so the container can talk to Ollama, and restrict ports 8443/tcp and 28000:29999/tcp to your Pentest laptop’s IP address.
Step 4: Launch and Verify the Stack
Start the containers in detached mode:
1
docker compose up -dWatch the containers initialize and verify that
pentagi,pgvector, andneo4jreport healthy/running status:1
docker compose ps
Run PentAGI’s built-in tool-calling and embedding diagnostics to confirm your abliterated model properly parses function schemas before starting a test:
1 2
docker exec -it pentagi /opt/pentagi/bin/ctester -verbose docker exec -it pentagi /opt/pentagi/bin/etester test -verbose
Note: If
ctesterreports JSON formatting issues on specific agent roles, you can adjust per-agent temperature or fallback settings later via the web UI under Settings -> Providers.
Step 5: Connect from the Pentest Laptop
Open a browser on your Kali laptop and navigate to:
1
https://<ARCH_LAN_IP>:8443
Accept the self-signed TLS certificate warning and log in with the default credentials:
- Email:
admin@pentagi.com - Password:
admin
- Email:
Immediately change the default admin password in your profile settings, verify your Ollama provider is active under Settings -> Providers, and launch a test flow scoped strictly to an isolated vulnerable VM or container on your lab network.
Wrapping Up
Deploying PentAGI alongside an abliterated local model on a single 24GB GPU proves that multi-agent offensive security workflows no longer require cloud APIs, enterprise budgets, or external telemetry leaks. By capping the context window at 32K, enabling Flash Attention with quantized KV caching, and validating tool-calling schemas upfront with ctester, you get a self-contained, air-gapped proving ground capable of chaining reconnaissance into exploitation completely autonomously.
For security researchers and defenders alike, the real value of this setup goes beyond automating lab captures. Observing how an unconstrained local agent enumerates services, recovers from failed payloads, and generates non-human traffic bursts gives you the exact behavioral telemetry needed to build stronger detections—before those same local workflows show up on your perimeter.