Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: use configured known_hosts path for SSH sandbox (#20114)

buua4369785a0dd2667
diff --git a/docker/.env-go b/docker/.env-go
index 26078c60d7..7ffa18e0f8 100644
--- a/docker/.env-go
+++ b/docker/.env-go
@@ -423,8 +423,11 @@ DISABLE_PASSWORD_LOGIN=false
# -----------------------------------------------------------------------------
# Native Go MCP listener settings
# -----------------------------------------------------------------------------
+RAGFLOW_SSH_KNOWN_HOSTS=${HOME}/.ssh/known_hosts
+SSH_KNOWN_HOSTS=/etc/ragflow/ssh_known_hosts
+
# RAGFLOW_MCP_ENABLED=true
# RAGFLOW_MCP_HOST=0.0.0.0
# RAGFLOW_MCP_PORT=9382
# RAGFLOW_MCP_LAUNCH_MODE=self-host
-# RAGFLOW_MCP_HOST_API_KEY=
\ No newline at end of file
+# RAGFLOW_MCP_HOST_API_KEY=
diff --git a/docker/docker-compose-go.yml b/docker/docker-compose-go.yml
index c97411436b..88cb4622ca 100644
--- a/docker/docker-compose-go.yml
+++ b/docker/docker-compose-go.yml
@@ -64,6 +64,7 @@ services:
# - ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./service_conf.yaml.template:/ragflow/conf/service_conf.yaml.template
- ./entrypoint-go.sh:/ragflow/entrypoint.sh
+ - ${RAGFLOW_SSH_KNOWN_HOSTS:-${HOME}/.ssh/known_hosts}:${SSH_KNOWN_HOSTS:-/etc/ragflow/ssh_known_hosts}:ro
env_file: .env-go
# Route the Go services' cache/queue backend to the separate Kvrocks service.
# The Python services use the Valkey `redis` service, which the Go deployment
@@ -114,6 +115,7 @@ services:
# - ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./service_conf.yaml.template:/ragflow/conf/service_conf.yaml.template
- ./entrypoint-go.sh:/ragflow/entrypoint.sh
+ - ${RAGFLOW_SSH_KNOWN_HOSTS:-${HOME}/.ssh/known_hosts}:${SSH_KNOWN_HOSTS:-/etc/ragflow/ssh_known_hosts}:ro
env_file: .env-go
# Route the Go services' cache/queue backend to the separate Kvrocks service.
# The Python services use the Valkey `redis` service, which the Go deployment
diff --git a/internal/agent/sandbox/ssh.go b/internal/agent/sandbox/ssh.go
index 04e24a3fa4..3449e30678 100644
--- a/internal/agent/sandbox/ssh.go
+++ b/internal/agent/sandbox/ssh.go
@@ -513,12 +513,16 @@ func (p *SSHProvider) hostKeyCallback() (ssh.HostKeyCallback, error) {
files = append(files, file)
}
}
- if p.knownHosts != "" {
- files = append(files, p.knownHosts)
+ knownHosts := p.knownHosts
+ if knownHosts == "" {
+ knownHosts = common.GetEnv(common.EnvSSHKnownHosts)
+ }
+ if knownHosts != "" {
+ files = append(files, knownHosts)
}
callback, err := knownhosts.New(files...)
if err != nil {
- return nil, fmt.Errorf("ssh: load known_hosts %q: %w", p.knownHosts, err)
+ return nil, fmt.Errorf("ssh: load known_hosts %q: %w", knownHosts, err)
}
return callback, nil
}