Skip to content
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

ssh: Allow forwardAgent to be set to null #6046

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tebriel
Copy link

@tebriel tebriel commented Nov 6, 2024

Description

Allow setting the forwardAgent to null to prevent it from being set in Host *.

In situations where you use CanonicalizeHostname and CanonicalDomains the ssh config is parsed twice. THe first time a value is set, typically means it's the final value. This means that if programs.ssh.forwardAgent is set to false you cannot have ForwardAgent = yes apply to a canonical match (Match canonical *.my.tld) as Host * will be parsed first.

If we consider the config where programs.ssh.forwardAgent = false;:

CanonicalizeHostanme yes
CanonicalizeDomains my.tld
CanonicalizeMaxDots 1

Match canonical Host *.my.tld
  ForwardAgent yes

Host *
  ForwardAgent no

ssh myhost will first pass through Host * and set ForwardAgent no, canonicalize the name to myhost.my.tld, then match Match canonical *.my.tld and try to set ForwardAgent to yes but since it's already no it will be ignored.

The same is a problem in reverse if programs.ssh.forwardAgent = true; and the canonical match is ForwardAgent no.

The default for forwardAgent is already false so there's not a need to always explicitly set it, we allow forwardAgent = null in match blocks, we can set it to null in the root as well.

Note

This does add a blank line if forwardAgent is set to null in the Host * block. Mabye not ideal, can probably fix it if it's really a problem.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

Allow the option to not explicitly set `ForwardAgent` in the `Host *`
block for instances where `CanonicalizeHostname` is enabled and the file
is parsed twice.
@tebriel tebriel marked this pull request as ready for review November 6, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant