Open
Description
I'm trying to block the handler whenever a reverse port forwarding was requested. The tunnel should exist as long as the user stops the SSH session by entering the Ctrl+C sequence. There is a Signals function that I would expect to do this, but nothing arrives at the channel in my testing code:
func handler(s ssh.Session) {
// ...
if requestedRevPortForwarding { // set in the reversePortForwardingHandler using ctx.SetValue()
io.WriteString(s, "[*] Forwarding initialized!\n")
io.WriteString(s, "[*] Stop with Ctrl+C")
signals := make(chan ssh.Signal, 10)
s.Signals(signals)
go func() {
for {
fmt.Println(<-signals)
}
}()
}
<-s.Context().Done() // block
// ...
}
With this example the user can only exit the session by closing the terminal he's in. There must be a way to handle this with signals. I know that I can use terminals to get like a "quit" command, but I want to use the Ctrl+C approach here.
Any idea why this is not working or an alternative to solve this?
Metadata
Metadata
Assignees
Labels
No labels