Ollama Has No API Authentication: How To Properly Gate Port 11434
说明与用途
Ollama 的未认证 API 通过 11434 端口暴露完整的模型控制。解决方案是将服务器绑定到 127.0.0.1 并/或使用 SSH 隧道、VPN 或带令牌的反向代理来保护模型、磁盘和 GPU。
问题
Ollama’s HTTP API on port 11434 is unauthenticated, allowing anyone who can reach the port to list, pull, delete, and run inference on models, posing a severe security risk.
结果
By binding Ollama to localhost and/or placing a secure proxy or tunnel in front of it, users eliminate unauthenticated access to the API, protecting models, disk space, and GPU resources.
工作流
- 1. Verify current bind address with OS‑specific commands (ss, lsof, netstat).
- 2. Test reachability from a local device and from outside the network to confirm exposure.
- 3. Audit the model directory for unexpected models or disk usage spikes.
- 4. Decide on a gating method based on user profile (local, VPN, SSH tunnel, reverse proxy).
- 5. Configure the chosen method: set OLLAMA_HOST to 127.0.0.1:11434 for local use; set up SSH tunnel or VPN; or deploy a reverse proxy with bearer token and HTTPS.
- 6. Apply platform‑specific environment settings (systemd unit, launchctl, Windows env vars).
- 7. Restart Ollama service or app to apply changes.
- 8. Re‑run reachability tests to confirm the port is no longer exposed.
- 9. Document the configuration and schedule periodic audits.
证据
Ollama has no username, no password and no API key. Anything that can reach TCP port 11434 can list your models, run inference on your GPU, pull a 40 GB model onto your disk and delete every model you have, with a single curl command and no credential.
The fix is not a setting inside Ollama, because there is not one: you keep the default bind on 127.0.0.1, and if you genuinely need remote access you put a bearer token proxy, an SSH tunnel or a mesh VPN in front of it.
- 记录日期: 2026-09-05T18:45:20.054Z