scripts: Zugang auch für Infra-Container (Hostschlüssel per pct exec, Knoten nach HA-Umzug)
ci / test (push) Successful in 30s
ci / test (push) Successful in 30s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
bf20da1629
commit
56576c7d3c
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Zugang zu den GPU-VMs auffrischen (läuft auf ops, im Verzeichnis platform/proxmox/tofu, mit
|
||||
# Zugang zu den GPU-VMs und Infra-Containern auffrischen (läuft auf ops, im Verzeichnis platform/proxmox/tofu, mit
|
||||
# geladenem /root/.config/knaster/tofu.env). Nötig nach jedem VM-Neustart, solange die Gäste per
|
||||
# DHCP ohne Reservierung laufen (D5): Adressen können wechseln (12.10. zwei VMs vertauscht).
|
||||
#
|
||||
@@ -25,3 +25,17 @@ for name, v in json.load(sys.stdin).items():
|
||||
echo "$ip $key" >> ~/.ssh/known_hosts
|
||||
echo "$name ($ip): $(ssh-keygen -lf <(echo "$ip $key") | awk '{print $2}')"
|
||||
done
|
||||
|
||||
# Infra-Container: Hostschlüssel über pct exec (Container hat keinen Gast-Agenten)
|
||||
tofu output -json infra_containers | python3 -c '
|
||||
import json, sys
|
||||
for name, v in json.load(sys.stdin).items():
|
||||
if v.get("ipv4"):
|
||||
print(name, v["node"], v["vmid"], v["ipv4"])
|
||||
' | while read -r name node vmid ip; do
|
||||
node=$(ssh -n pve44 "pvesh get /cluster/resources --type vm --output-format json" | python3 -c "import json,sys; print(next(r['node'] for r in json.load(sys.stdin) if r['vmid']==$vmid))")
|
||||
key=$(ssh -n "$node" "pct exec $vmid -- cat /etc/ssh/ssh_host_ed25519_key.pub")
|
||||
ssh-keygen -R "$ip" >/dev/null 2>&1 || true
|
||||
echo "$ip $key" >> ~/.ssh/known_hosts
|
||||
echo "$name ($ip, $node): $(ssh-keygen -lf <(echo "$ip $key") | awk '{print $2}')"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user