Zuerst brauchst du ein Cookie und einen CSRF-Token. Beides generierst du über die API. So generierst du das Cookie:
curl --silent --insecure --data "username=root@pam&password=yourpassword" \
https://10.0.0.23:8006/api2/json/access/ticket\
| jq --raw-output '.data.ticket' | sed 's/^/PVEAuthCookie=/' > cookie
Und so generierst du den CSRF Token:
curl --silent --insecure --data "username=root@pam&password=yourpassword" \
https://10.0.0.23:8006/api2/json/access/ticket \
| jq --raw-output '.data.CSRFPreventionToken' | sed 's/^/CSRFPreventionToken:/' > csrftoken
Um zu prüfen ob die Authentifizierung klappt kannst du diesen Statusbefehl aufrufen
curl --insecure --cookie "$(<cookie)" https://10.0.0.23:8006/api2/json/nodes/pve/status | jq '.'
Wenn das funktioniert kannst du mit dem Cookie und dem CSRF Token zusammen einen Container erstellen.
curl -sk --insecure --cookie "$(<cookie)" --header "$(<csrftoken)" -X POST https://10.0.0.23:8006/api2/json/nodes/pve/lxc \
-d vmid=101 \
-d hostname=test-container \
-d ostemplate=local:vztmpl/ubuntu-22.04.tar.zst \
-d memory=512 \
-d cores=1 \
-d rootfs="local-lvm:8" \
-d unprivileged=1)