disable hostkeychecking for ssh from containers

This commit is contained in:
2025-11-13 22:47:18 +01:00
parent 59b9557013
commit 10779e7cea

View File

@@ -5,6 +5,7 @@ import (
"context" "context"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"sort" "sort"
"strconv" "strconv"
@@ -267,6 +268,14 @@ func (sc *SSHConnector) runRemoteCommand(ctx context.Context, command []string)
func (sc *SSHConnector) buildSSHArgs(command []string) []string { func (sc *SSHConnector) buildSSHArgs(command []string) []string {
args := []string{"-o", "BatchMode=yes"} args := []string{"-o", "BatchMode=yes"}
// In containerized environments, disable strict host key checking
if _, container := os.LookupEnv("CONTAINER"); container {
args = append(args,
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "LogLevel=ERROR",
)
}
if sc.server.SSHKeyPath != "" { if sc.server.SSHKeyPath != "" {
args = append(args, "-i", sc.server.SSHKeyPath) args = append(args, "-i", sc.server.SSHKeyPath)
} }