Repository navigation
cli: include the port in the ssh-terminfo cache key - #14472
Merged
Merged
Conversation
The ssh-terminfo cache keyed destinations as user@hostname from `ssh -G`, ignoring the port. Two machines behind one address on different ports (e.g. user@host:2221 and user@host:2218) shared a key, so once the first was cached the terminfo install was skipped for the second, which still got TERM=xterm-ghostty without the terminfo installed. The key now carries the port when it isn't 22: user@host:port, or user@[addr]:port for IPv6. Port 22 keeps the old user@host form, so existing caches stay valid. `+ssh-cache` accepts the new form: a bare `host` query matches that host on every port, a bare `host:port` query that port for any user, and `user@host:port` one exact entry. AI disclosure: the cause was found and the patch written with Claude Code (Claude Opus 5.5). Reviewed and tested by me.
jparise
reviewed
Oct 1, 2026
jparise
left a comment
Contributor
There was a problem hiding this comment.
Looks good! Just spotted a few small things.
- matchesQuery treats a missing port as port 22. - isValidPort uses std.ascii.isDigit and rejects leading zeros, so host:22 and host:022 can't become distinct keys.
Contributor
Author
|
Thanks for the review! All three addressed:
Tests added for each. |
jparise
approved these changes
Oct 3, 2026
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.
The ssh-terminfo cache keyed destinations as user@hostname from
ssh -G, ignoring the port. Two machines behind one address on different ports (e.g. user@host:2221 and user@host:2218) shared a key, so once the first was cached the terminfo install was skipped for the second, which still got TERM=xterm-ghostty without the terminfo installed.The key now carries the port when it isn't 22: user@host:port, or user@[addr]:port for IPv6. Port 22 keeps the old user@host form, so existing caches stay valid.
+ssh-cacheaccepts the new form: a barehostquery matches that host on every port, a barehost:portquery that port for any user, anduser@host:portone exact entry.AI disclosure: the cause was found and the patch written with Claude Code (Claude Opus 5.5). Reviewed and tested by me.
Discussed in #14465.