Files

102 lines
3.9 KiB
Markdown
Raw Permalink Normal View History

---
name: code-gurix-dev
description: Zugriff auf die private Gitea-Instanz code.gurix.dev — Repos klonen/pushen via SSH (Tailnet, Port 2222), API via HTTPS für Repos/Issues/PRs. Nutzen, wenn mit Repositories auf code.gurix.dev gearbeitet wird (clone, push, Issues, PRs) oder der Zugang dafür eingerichtet werden soll.
---
# Gitea auf code.gurix.dev
Gitea (v1.27.x), läuft als Docker-Container auf Host **carson**.
Zwei Zugangswege:
| Weg | URL | Wofür |
|-------|----------------------------------------------|--------------------------------|
| API | `https://code.gurix.dev` | Issues, PRs, Releases, Suche |
| Git | `ssh://git@carson.monster-wezen.ts.net:2222` | Clone / Pull / Push (Tailnet!) |
**Wichtig:** `code.gurix.dev:2222` funktioniert **nicht** — die öffentliche IP
(89.167.88.65) forwarded keinen SSH-Port. Git immer über den Tailnet-Namen von
carson (`carson.monster-wezen.ts.net`, Tailscale-IP `100.109.222.33`).
Auf carson selbst ist die API zusätzlich unter `http://localhost:3001` erreichbar.
## Voraussetzungen (einmalig pro Agent/Maschine)
1. **API-Token** ablegen:
- Pfad: `~/.pi/agent/.credentials/gitea-token` (nur der Token, `chmod 600`)
- Erzeugen in Gitea: Profil → Einstellungen → Anwendungen → *Token generieren*
(Scopes: repository read/write, user read).
2. **SSH-Key** deponieren und in Gitea hinterlegen:
- Key z. B. unter `~/.ssh/id_ed25519` bzw. dedizierter Key `~/.ssh/gitea_ed25519`
- Public Key in Gitea: Profil → Einstellungen → SSH-Schlüssel
3. **SSH-Host-Alias** in `~/.ssh/config` — damit funktionieren die
`ssh://git@code.gurix.dev:2222/...`-URLs aus der API unverändert:
```
Host code.gurix.dev
HostName carson.monster-wezen.ts.net
Port 2222
User git
IdentityFile ~/.ssh/gitea_ed25519
IdentitiesOnly yes
```
4. Host-Key einmalig aufnehmen:
```bash
ssh-keyscan -p 2222 -t ed25519 carson.monster-wezen.ts.net >> ~/.ssh/known_hosts
```
## Verbindung testen
```bash
TOKEN_FILE=~/.pi/agent/.credentials/gitea-token
# 1) API (erwartet: Username als JSON, HTTP 200)
curl -s -H "Authorization: token $(cat $TOKEN_FILE)" https://code.gurix.dev/api/v1/user
# 2) SSH (erwartet: "Hi there, <user>! ... Gitea does not provide shell access.")
ssh -p 2222 git@carson.monster-wezen.ts.net
# 3) Git (erwartet: HEAD-Commit-Hash)
git ls-remote ssh://git@carson.monster-wezen.ts.net:2222/<owner>/<repo>.git HEAD
```
## Git-URLs
```bash
# SSH (empfohlen, nur im Tailnet — Via Host-Alias geht auch: git@code.gurix.dev:...)
git clone ssh://git@carson.monster-wezen.ts.net:2222/<owner>/<repo>.git
# HTTPS mit Token (Fallback; Token nie in Shellhistory/Logs/Remotes committen)
git clone https://<user>:$(cat $TOKEN_FILE)@code.gurix.dev/<owner>/<repo>.git
```
Hinweis: Die `ssh_url` aus der API nennt `code.gurix.dev:2222` — mit dem
Host-Alias aus Schritt 3 passt sie so, sonst Host durch
`carson.monster-wezen.ts.net` ersetzen.
## API-Beispiele
```bash
API=https://code.gurix.dev/api/v1
AUTH="Authorization: token $(cat ~/.pi/agent/.credentials/gitea-token)"
# Eigene Repos listen (Namen)
curl -s -H "$AUTH" "$API/user/repos?limit=50" | python3 -c \
"import json,sys; [print(r['full_name']) for r in json.load(sys.stdin)]"
# Repo anlegen
curl -s -X POST -H "$AUTH" -H 'Content-Type: application/json' \
-d '{"name":"neues-repo","private":true,"auto_init":true}' \
"$API/user/repos"
# Issues / Pull Requests
curl -s -H "$AUTH" "$API/repos/<owner>/<repo>/issues?state=open"
curl -s -H "$AUTH" "$API/repos/<owner>/<repo>/pulls?state=open"
```
## Regeln
- Token **niemals** in Chat-Ausgaben, Logs, URLs oder Commits ausgeben —
immer via `$(cat ...)`.
- Außerhalb des Tailnet: erst Tailscale/WireGuard verbinden (oder SSH-Jump über
carson), sonst schlägt Port 2222 fehl.
- API funktioniert von überall (HTTPS); Git/Push nur im Tailnet.