Attribute gated sessions in correlate via the backend port - #50
Merged
Merged
Conversation
Behind sshgate, sshd logs every session as `from 127.0.0.1 port N`, so correlate's client-IP match found nothing. correlate now reads sshgate's CONNECTED lines for the fingerprint (--gate-log, default /var/log/syslog) and joins each loopback sshd line to the one with the same host and port nearest in time within --join-window (10s), reporting the client address with SOURCE gate:<port>. Lines from a real client address keep the existing IP match near first/last seen (SOURCE direct). A missing gate log warns and falls back. Also fixes the user shown for "for invalid user <name>" lines, which was "user". 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
Behind sshgate, sshd logs every session as
from 127.0.0.1 port N, socorrelate's client-IP match found nothing for gated sessions — on hosts where sshd listens only on loopback, that is every session. v0.6.0 added theCONNECTED ... local=127.0.0.1:Nline that makes the join possible (#48).What
--gate-log(default/var/log/syslog, where rsyslog copies sshgate's journal on Debian): read the fingerprint'sCONNECTEDlines.CONNECTEDline with the same host and port nearest in time within--join-window(default 10s), and reported with the client address from the gate andSOURCE gate:<port>. Ports are reused, so nearest-within-window, and host must match when both lines carry one.SOURCE direct).for invalid user <name>lines was reported asuser.correlate(correlate_test.go); docs updated.Testing
go test -race ./...,go vet, golangci-lint v2.14.0 clean.auth.logandsyslog: 599CONNECTEDlines for the macbook fingerprint; gatedsshd-sessionlogins were attributed to the real client address (before: no matches).🤖 Generated with Claude Code