fix: remove public key deployment from deploy-keys

Deploy-keys now only:
- Creates /var/lib/syncserver/ssh/keys on remote
- Uploads private keys of all other machines to that path
- Populates known_hosts with all other machine hosts

No longer touches authorized_keys or reads server public key.
This commit is contained in:
2026-07-09 20:58:48 -04:00
parent 048b99921e
commit c7337a3bbc
4 changed files with 5 additions and 40 deletions
+2 -14
View File
@@ -7,7 +7,6 @@ import (
"fmt"
"log/slog"
"net/http"
"os"
"path/filepath"
"regexp"
"strconv"
@@ -341,8 +340,8 @@ func (h *MachineHandler) DeployKeys(w http.ResponseWriter, r *http.Request) {
}
var req struct {
KnownHostsHost string `json:"known_hosts_host"`
IncludeServerKey bool `json:"include_server_key"`
KnownHostsHost string `json:"known_hosts_host"`
IncludeServerKey bool `json:"include_server_key"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
writeError(w, http.StatusBadRequest, "invalid request body")
@@ -350,7 +349,6 @@ func (h *MachineHandler) DeployKeys(w http.ResponseWriter, r *http.Request) {
}
serverKeyPath := h.cfg.SSHDir() + "/id_ed25519"
serverPubKeyPath := h.cfg.SSHDir() + "/id_ed25519.pub"
if m.SSHKeyID != nil {
sshKeyRepo := models.NewSSHKeyRepository(h.db)
@@ -360,14 +358,6 @@ func (h *MachineHandler) DeployKeys(w http.ResponseWriter, r *http.Request) {
}
}
serverPubKey := ""
if req.IncludeServerKey {
data, err := os.ReadFile(serverPubKeyPath)
if err == nil {
serverPubKey = string(data)
}
}
allMachines, err := repo.GetAll()
if err != nil {
slog.Warn("failed to fetch machines for auto-detect", "error", err)
@@ -406,13 +396,11 @@ func (h *MachineHandler) DeployKeys(w http.ResponseWriter, r *http.Request) {
result, err := sshmanager.DeployKeysToMachine(
context.Background(),
serverKeyPath,
serverPubKey,
m.Host,
m.Port,
m.SSHUser,
keys,
knownHostsHosts,
req.IncludeServerKey,
)
if err != nil {
writeError(w, http.StatusInternalServerError, err.Error())