Skip to content

Make the HostConfigEntry accessible in the AbstractClientSession #728

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

Open
tomaswolf opened this issue Apr 12, 2025 · 0 comments
Open

Make the HostConfigEntry accessible in the AbstractClientSession #728

tomaswolf opened this issue Apr 12, 2025 · 0 comments
Labels
feature request A request for a new feature
Milestone

Comments

@tomaswolf
Copy link
Member

Description

The HostConfigEntry used in SshClient should be forwarded to the to-be-created ClientSession. This can be done via the "connectionContext" AttributeRepository. This one gets passed from the SshClient to the IoConnector, and gets attached to the IoSession that is created. The AbstractClientSession already extracts it from the IoSession and makes it available via getConnectionContext().

So the SshClient just has to add the HostConfigEntry as an attribute there, and the AbstractClientSession can then retrieve that attribute and make it available via a new getHostConfigEntry() convenience method.

Motivation

A client session needs to know the HostConfigEntry, and it needs to know it before it is started. The host entry might contain configurations relevant already for the initial key exchange, such as cipher, mac, or host key signature algorithm settings.

Propagating such information only after the SSH session has been created and started is too late.

Alternatives considered

Setting properties from the host entry somewhere where the to-be-created session can find them. But where? Such properties cannot be set on the session itself since it doesn't exist yet. Setting them on the client won't work because the settings are specific to the new session, but a client can created many sessions. We'd risk using the wrong settings for the wrong sessions.

This extra "connection context" AttributeRepository appears to be the right place, provided the SshClient can make sure it gives each session its own such attribute repository (which is possible).

Additional context

JGit has implemented that years ago in their SSH transport.

@tomaswolf tomaswolf added the feature request A request for a new feature label Apr 12, 2025
@tomaswolf tomaswolf added this to the 3.0.0 milestone Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request for a new feature
Projects
None yet
Development

No branches or pull requests

1 participant