Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote port forwarding is failed #291

Open
Nick1994209 opened this issue Aug 11, 2021 · 4 comments
Open

Remote port forwarding is failed #291

Nick1994209 opened this issue Aug 11, 2021 · 4 comments

Comments

@Nick1994209
Copy link

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?

@strazto
Copy link

strazto commented Sep 7, 2021

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)

@xentac
Copy link

xentac commented Oct 6, 2021

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.

@badrbouslikhin
Copy link

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

@EBADBEEF
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants