Skip to content

cli: Add Explicit key selection#949

Closed
karpfediem wants to merge 2 commits into
purpleidea:masterfrom
karpfediem:feature/ssh-deploy-id
Closed

cli: Add Explicit key selection#949
karpfediem wants to merge 2 commits into
purpleidea:masterfrom
karpfediem:feature/ssh-deploy-id

Conversation

@karpfediem

@karpfediem karpfediem commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Adds a --ssh-id CLI flag to select an exact SSH private key path.
This sets the internal SSHID variable (etcd/ssh/ssh.go), which was previously not exposed directly.

With an unset/empty SSHID we collect SSH client signers only by scanning the default SSH directory for id_* private keys.

This change exposes the existing SSHID field as an explicit single-key alternative.

Why this was needed:

  • My PK files are not neccessarily under ~/.ssh
  • The current scan does not respect a custom HOME override
    ExpandHome ends up using the actual user home setting via os.user
	if strings.HasPrefix(p, "~/") {
		usr, err := user.Current()
		if err != nil {
			return p, fmt.Errorf("can't expand ~ into home directory")
		}
		return path.Join(usr.HomeDir, p[len("~/"):]) + suffix, nil
	}

Adds a --ssh-id CLI flag to select an exact SSH private key path.
This sets the internal `SSHID` variable (`etcd/ssh/ssh.go`), which was previously not exposed directly.

With an unset/empty `SSHID` we collect SSH client signers only by scanning the default SSH directory for `id_*` private keys.

This change exposes the existing `SSHID` field as an explicit single-key alternative.

Why this was needed:
- My PK files are not neccessarily under ~/.ssh
- The current scan does not respect a custom HOME override
ExpandHome ends up using the actual user home setting via os.user
@karpfediem karpfediem force-pushed the feature/ssh-deploy-id branch from 31ece9d to 6e1b430 Compare June 30, 2026 14:45
@purpleidea

Copy link
Copy Markdown
Owner

If LLM/AI was used in this commit, it must be disclosed. Please confirm, and thank you.

@purpleidea

Copy link
Copy Markdown
Owner

Otherwise, patch LGTM, except you may wish to also plumb things through in lang/core/embedded/provisioner/main.mcl

Look for --ssh-hostkey and append the new arg everywhere that is seen... Should be an easy pattern match addition.

Thanks!

@karpfediem

Copy link
Copy Markdown
Contributor Author

If LLM/AI was used in this commit, it must be disclosed. Please confirm, and thank you.

Both commits were written by me, without AI this time.

I've added the new flag to the embedded provisioner module code. Although they're really just going to be empty for now. Until the module code does anything fancy, like allowing to install a custom private key on the new host instead of auto-generating it.

@purpleidea

Copy link
Copy Markdown
Owner

I've squashed and reflowed the commit message and merged! Thank you.

@purpleidea purpleidea closed this Jul 5, 2026
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.

2 participants