-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix remote port forwarding reporting wrong hostname #48831
Conversation
This pull request is automatically being deployed by Amplify Hosting (learn more). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with root/leaf Teleport/Agentless nodes 👍
lib/srv/regular/sshserver_test.go
Outdated
// Dial the test server over the SSH connection. | ||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
t.Cleanup(cancel) | ||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, ts.URL, &bytes.Buffer{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req, err := http.NewRequestWithContext(ctx, http.MethodGet, ts.URL, &bytes.Buffer{}) | |
req, err := http.NewRequestWithContext(ctx, http.MethodGet, ts.URL, nil) |
lib/srv/regular/sshserver_test.go
Outdated
client := &http.Client{} | ||
resp, err := client.Do(req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client := &http.Client{} | |
resp, err := client.Do(req) | |
resp, err := ts.Client().Do(req) |
lib/srv/regular/sshserver.go
Outdated
@@ -2194,8 +2194,17 @@ func (s *Server) handleTCPIPForwardRequest(ctx context.Context, ccx *sshutils.Co | |||
return trace.Wrap(err) | |||
} | |||
|
|||
// Set the src addr again since it may have been updated with a new port. | |||
scx.SrcAddr = listener.Addr().String() | |||
// Update the src addr port. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: expand this comment to include why this needs to happen.
This change fixes a bug in remote port forwarding where Teleport reports the hostname from the created remote listener, rather than the hostname requested in the tcpip-forward request.
66dbb95
to
ba6abfe
Compare
This change fixes a bug in remote port forwarding where Teleport reports the hostname from the created remote listener, rather than the hostname requested in the
tcpip-forward
request. In particular, clients that request a listener atlocalhost
would eventually receive aforwarded-tcpip
channel request from127.0.0.1
, which the client would not be able to map to the listener it requested.Fixes #48254.
Changelog: Fixed OpenSSH remote port forwarding not working for localhost