install: support -i flag for specifying SSH private key
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user