Repository navigation
Log backend local address for each forwarded connection - #48
Merged
Merged
Conversation
When sshd listens only behind sshgate it sees every client as the gate and logs "from 127.0.0.1 port N". Log a CONNECTED line after the backend dial with the socket's local address, so that port can be joined back to the real client IP and fingerprint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When
sshdlistens only behind sshgate (for example127.0.0.1:22), it sees every client as the gate and logsAccepted publickey for alice from 127.0.0.1 port 54321. The real client IP only exists in sshgate's log, and nothing ties the two together. That also meanssshgate correlate, which matches client IPs inauth.log, can't match sessions on hosts set up this way.What
localport is the portsshdreports, so the two lines can be joined on host + port + a short time window to recover client IP and fingerprint per authenticated session. It's logged after the approve/pending decision, so it covers approved and pending-allowed connections that actually reached the backend.TestConnectedLogsBackendLocalAddresschecks the logged address equals the peer address the backend sees (fails on the old code).docs/operations.md: short note on the join in the Correlate section.Updating
correlateitself to use this join is left for a follow-up.Testing
go vet ./...,gofmt -l .,go test -race ./...pass locally.🤖 Generated with Claude Code