sshportal icon indicating copy to clipboard operation
sshportal copied to clipboard

Remote port forwarding is failed

Open Nick1994209 opened this issue 4 years ago • 4 comments

When I try to connect using remote port forward, I get an error.

ssh -R 8000:localhost:8000 myusername@sshportalhost -p 2222 -i private_key Warning: remote port forwarding failed for listen port 8000 ssh connection is worked, but curl localhost:8000 from a remote server is not.

Can you help me, what I should do for using remote portforward?

Nick1994209 avatar Aug 11 '21 09:08 Nick1994209

Does this problem occur when not using sshportal?

(To clarify the purpose of asking, I'm wondering if it's possible this problem is related to something else, eg, that port already being bound by something)

strazto avatar Sep 07 '21 03:09 strazto

I can verify that sshportal causes the failure in remote port forwarding. Connecting directly to the system allows remote port forwarding whereas connecting through sshportal results in a failed forward.

xentac avatar Oct 06 '21 19:10 xentac

I have the same issue. Did you find the cause?

badrbouslikhin avatar Jul 05 '22 08:07 badrbouslikhin

I think I was able to trace this down into gliderlabs/ssh/server.go handleRequests(), there is no handler registered on the connection. By default we only register a ChannelHandler not a RequestHandler in server.go server() ssh.Server() (boy I learned a lot about ssh today).

func (srv *Server) handleRequests(ctx Context, in <-chan *gossh.Request) {
  for req := range in {
    handler := srv.RequestHandlers[req.Type]
    if handler == nil {
      fmt.Printf("USING DEFAULT HANDLER for %s\n", req.Type)
      handler = srv.RequestHandlers["default"]
    }
    if handler == nil {
      fmt.Printf("DEFAULT HANDLER EMPTY\n")
      req.Reply(false, nil)
      continue
    }
    /*reqCtx, cancel := context.WithCancel(ctx)
    defer cancel() */
    ret, payload := handler(ctx, srv, req)
    req.Reply(ret, payload)
  }
}

I get the following printout:

USING DEFAULT HANDLER for tcpip-forward
DEFAULT HANDLER EMPTY

"tcpip-forward" is the "global request" for remote port forwards (https://www.rfc-editor.org/rfc/rfc4254#section-7.1)

EBADBEEF avatar Mar 10 '23 01:03 EBADBEEF