diff --git a/lib/srv/forward/subsystem.go b/lib/srv/forward/subsystem.go index b8ae7335d0966..fbcb4957183e4 100644 --- a/lib/srv/forward/subsystem.go +++ b/lib/srv/forward/subsystem.go @@ -237,6 +237,14 @@ func (r *remoteSFTPSubsystem) Wait() error { err = trace.ConnectionProblem(nil, "context is closing") } + var exitStatus int + if err != nil { + exitStatus = 1 + } + r.subsystem.serverContext.SendExecResult(r.subsystem.ctx, srv.ExecResult{ + Code: exitStatus, + }) + // emit an event to the audit log with the result of execution r.subsystem.emitAuditEvent(r.subsystem.ctx, err) return trace.Wrap(err)