SSH connections are left dangling after use (#668)

This commit is contained in:
Frederik Ring
2025-11-09 17:28:31 +01:00
committed by GitHub
parent 95bf34280d
commit 9cb2ae1893
2 changed files with 22 additions and 11 deletions

View File

@@ -177,10 +177,20 @@ func (s *script) init() error {
IdentityPassphrase: s.c.SSHIdentityPassphrase,
RemotePath: s.c.SSHRemotePath,
}
sshBackend, err := ssh.NewStorageBackend(sshConfig, logFunc)
sshBackend, closeSSHConnection, err := ssh.NewStorageBackend(sshConfig, logFunc)
s.registerHook(hookLevelPlumbing, func(err error) error {
if err := closeSSHConnection(); err != nil {
return errwrap.Wrap(err, "failed to close ssh connection")
}
return nil
})
if err != nil {
return errwrap.Wrap(err, "error creating ssh storage backend")
}
s.storages = append(s.storages, sshBackend)
}