mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
fix: close stale ControlMaster ssh connection for machine init/add
This commit is contained in:
1 parent
102421df19
commit
fdbffbf020
3 files changed
+44
-14
No files matched your search
@@ -207,6 +207,16 @@ func (c *SSHCLIConnector) CheckTCPForwarding(ctx context.Context) error {
|
||||
return c.fwdCheckErr
|
||||
}
|
||||
|
||||
// CloseControlMaster terminates the SSH ControlMaster process for this destination so the next connection starts
|
||||
// a fresh SSH session. No-op if no master is running or the control socket is not configured. Errors are ignored.
|
||||
func (c *SSHCLIConnector) CloseControlMaster(ctx context.Context) {
|
||||
if c.controlSockPath == "" {
|
||||
return
|
||||
}
|
||||
args := append(c.buildSSHArgs(), "-O", "exit")
|
||||
_ = exec.CommandContext(ctx, "ssh", args...).Run()
|
||||
}
|
||||
|
||||
func (c *SSHCLIConnector) Close() error {
|
||||
// Individual connections are managed by gRPC and closed when the gRPC connection closes.
|
||||
// The SSH control socket may persist for connection reuse across CLI invocations.
|
||||
|
||||
Reference in new issue
Block a user