From 01d86b6482027b6e01f7244869dd54f240b2aac8 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 19 Jan 2025 18:07:42 +1100 Subject: [PATCH] install: support `-i` flag for specifying SSH private key --- pkgs/clan-cli/clan_cli/machines/install.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/clan-cli/clan_cli/machines/install.py b/pkgs/clan-cli/clan_cli/machines/install.py index dc051de61..7d60f78bd 100644 --- a/pkgs/clan-cli/clan_cli/machines/install.py +++ b/pkgs/clan-cli/clan_cli/machines/install.py @@ -36,6 +36,7 @@ class InstallOptions: nix_options: list[str] = field(default_factory=list) update_hardware_config: HardwareConfig = HardwareConfig.NONE password: str | None = None + identity_file: Path | None = None @API.register @@ -97,6 +98,9 @@ def install_machine(opts: InstallOptions) -> None: "IdentitiesOnly=yes", ] + if opts.identity_file: + cmd += ["-i", str(opts.identity_file)] + if not machine.can_build_locally or opts.build_on_remote: machine.info( f"Target machine has architecture {machine.system} which cannot be built locally or with the configured remote builders. Building on target machine" @@ -170,6 +174,7 @@ def install_command(args: argparse.Namespace) -> None: build_on_remote=args.build_on_remote, update_hardware_config=HardwareConfig(args.update_hardware_config), password=password, + identity_file=args.identity_file, ), ) except KeyboardInterrupt: @@ -233,10 +238,17 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None: help="ssh address to install to in the form of user@host:2222", ) add_dynamic_completer(target_host_parser, complete_target_host) - parser.add_argument( + authentication_group = parser.add_mutually_exclusive_group() + authentication_group.add_argument( "--password", help="specify the password for the ssh connection (generated by starting the clan installer)", ) + authentication_group.add_argument( + "-i", + dest="identity_file", + type=Path, + help="specify which SSH private key file to use", + ) group.add_argument( "-P", "--png",