Skip to content

Commit

Permalink
Add remote port forwarding for Teleport nodes (#38828)
Browse files Browse the repository at this point in the history
* Add remote port forwarding for Teleport nodes

This change adds support for remote port forwarding (ssh -R) for
Teleport nodes.

* Fix windows build
  • Loading branch information
atburke committed Mar 16, 2024
1 parent a473cb5 commit 064aae0
Show file tree
Hide file tree
Showing 17 changed files with 1,079 additions and 108 deletions.
12 changes: 11 additions & 1 deletion lib/srv/reexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,17 @@ func handleLocalPortForward(ctx context.Context, addr string, file *os.File) err
}

func createRemotePortForwardingListener(ctx context.Context, addr string) (*os.File, error) {
var lc net.ListenConfig
lc := net.ListenConfig{
Control: func(network, addr string, conn syscall.RawConn) error {
var err error
err2 := conn.Control(func(descriptor uintptr) {
// Disable address reuse to prevent socket replacement.
err = syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 0)
})
return trace.NewAggregate(err2, err)
},
}

listener, err := lc.Listen(ctx, "tcp", addr)
if err != nil {
return nil, trace.Wrap(err)
Expand Down

0 comments on commit 064aae0

Please sign in to comment.