feat: make SSH agent forwarding and identity agent configurable#8
Merged
Conversation
Replace hardcoded '-A -o IdentityAgent=$SSH_AUTH_SOCK' in nixos-rebuild
with two configurable variables:
- forward_agent (bool, default false): controls the -A SSH flag
- identity_agent (bool, default true): controls -o IdentityAgent, guarded
with bash ${SSH_AUTH_SOCK:+...} so it only takes effect when
SSH_AUTH_SOCK is set (fixes error when SSH_AUTH_SOCK is empty)
Both variables are passed through from nixos-deploy module.
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.
Summary
-A -o IdentityAgent=$SSH_AUTH_SOCKinnixos-rebuildwith two configurable variables:forward_agentandidentity_agentSSH_AUTH_SOCKis empty/unset — the-o IdentityAgent=(with empty value) causes SSH to failnixos-deploymoduleDetails
New variables
forward_agentboolfalse-ASSH flag for agent forwardingidentity_agentbooltrue-o IdentityAgent=$SSH_AUTH_SOCK, guarded with bash${SSH_AUTH_SOCK:+...}How it works
The SSH options are now built dynamically using
compact/join:identity_agent = true(default): Uses bash parameter expansion${SSH_AUTH_SOCK:+-o IdentityAgent=$SSH_AUTH_SOCK}so the option is only added whenSSH_AUTH_SOCKis actually set and non-emptyforward_agent = false(default): Agent forwarding is off — not needed for standardnixos-rebuild --target-hostdeploys where all SSH is local→remoteBug fixed
Previously, when
SSH_AUTH_SOCKwas empty (e.g. in Terraformlocal-execwithout agent), the command expanded to-o IdentityAgent=which is an SSH error. The bash guard${SSH_AUTH_SOCK:+...}prevents this.Affected modules
modules/nixos-rebuild— newlocalsblock, updatedlocal-execcommand, two new variablesmodules/nixos-deploy— passthrough offorward_agentandidentity_agentto innernixos-rebuildmodule