Skip the in-loop defer of channel closure
That's not how defer works.  We are already properly closing the channel
elsewhere, and while it's a bit awkward to close the channel, continue
the loop and immediately exit via the loop conditional, it does
function.
@@ -103,8 +103,6 @@ func (agent *Agent) handleConn(conn *ssh.ServerConn, chans <-chan ssh.NewChannel
return
}
- defer channel.Close()
-
for req := range requests {
if req.Type != "exec" {
log.Errorf("rejecting non-exec channel request (type=%s)\n", req.Type)
