Skip to content

Commit 3b970a6

Browse files
andystimeclaude
andcommitted
fix: remove EnsureSSHServer call and fix authorized_keys permissions
- Remove EnsureSSHServer() call in manager.go that was overriding setupSSHInContainer() config - Fix authorized_keys ownership with chown root:root - Attempt to work around ld.so.preload GPU library logging issue - Remove unused klog import from manager.go The old EnsureSSHServer() was being called after setupSSHInContainer(), overriding the secure SSH configuration (PasswordAuthentication no, PermitRootLogin prohibit-password) with insecure defaults. This caused containers to still have password authentication enabled despite setupSSHInContainer() setting it to disabled. Known issue: TensorFusion GPU libraries loaded via /etc/ld.so.preload interfere with SSH protocol. The preload file is read-only mounted and cannot be modified at runtime. This requires a fix in the TensorFusion GPU library to suppress logging during SSH sessions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 3dbfe28 commit 3b970a6

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

internal/studio/manager.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
"github.com/NexusGPU/gpu-go/internal/errors"
1919
"github.com/NexusGPU/gpu-go/internal/platform"
20-
"k8s.io/klog/v2"
2120
)
2221

2322
var (
@@ -223,12 +222,15 @@ func (m *Manager) Create(ctx context.Context, opts *CreateOptions) (*Environment
223222
return nil, err
224223
}
225224

226-
// Setup SSH server if backend supports it
227-
if sshBackend, ok := backend.(SSHServerBackend); ok {
228-
if err := sshBackend.EnsureSSHServer(ctx, env.ID); err != nil {
229-
klog.Warningf("Failed to setup SSH server: %v (continuing anyway)", err)
230-
}
231-
}
225+
// SSH server is now set up by setupSSHInContainer() during container creation
226+
// No need to call EnsureSSHServer which would override the secure configuration
227+
//
228+
// // Setup SSH server if backend supports it
229+
// if sshBackend, ok := backend.(SSHServerBackend); ok {
230+
// if err := sshBackend.EnsureSSHServer(ctx, env.ID); err != nil {
231+
// klog.Warningf("Failed to setup SSH server: %v (continuing anyway)", err)
232+
// }
233+
// }
232234

233235
m.clearUnreachableSSH(ctx, env)
234236

internal/studio/ssh_setup.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,31 @@ echo "SSH setup completed successfully"
111111
if sshPublicKey != "" {
112112
klog.V(2).Infof("Adding SSH public key to container")
113113
addKeyCmd := execCmd("exec", containerID, "sh", "-c",
114-
fmt.Sprintf("echo '%s' >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys", sshPublicKey))
114+
fmt.Sprintf("echo '%s' >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys && chown root:root /root/.ssh/authorized_keys", sshPublicKey))
115115
if output, err := addKeyCmd.CombinedOutput(); err != nil {
116116
klog.Warningf("Failed to add SSH key (non-fatal): %v, output: %s", err, string(output))
117117
}
118118
}
119119

120120
// Start SSH daemon in background
121+
// Temporarily disable ld.so.preload to prevent GPU library logs from breaking SSH protocol
121122
klog.V(2).Infof("Starting SSH daemon in container")
122-
startSSHCmd := execCmd("exec", "-d", containerID, "/usr/sbin/sshd", "-D")
123+
startSSHScript := `
124+
# Temporarily disable ld.so.preload to prevent library logs from breaking SSH
125+
if [ -f /etc/ld.so.preload ]; then
126+
mv /etc/ld.so.preload /etc/ld.so.preload.disabled
127+
fi
128+
129+
# Start SSH daemon
130+
/usr/sbin/sshd -D &
131+
132+
# Re-enable ld.so.preload after sshd has forked
133+
sleep 1
134+
if [ -f /etc/ld.so.preload.disabled ]; then
135+
mv /etc/ld.so.preload.disabled /etc/ld.so.preload
136+
fi
137+
`
138+
startSSHCmd := execCmd("exec", "-d", containerID, "sh", "-c", startSSHScript)
123139
if output, err := startSSHCmd.CombinedOutput(); err != nil {
124140
klog.Errorf("Failed to start SSH daemon: %v, output: %s", err, string(output))
125141
return fmt.Errorf("failed to start SSH daemon: %w\nOutput: %s", err, string(output))

0 commit comments

Comments
 (0)