Skip to content

Commit

Permalink
reinstall: warn if no users with authorized ssh keys are found
Browse files Browse the repository at this point in the history
Signed-off-by: Omer Tuchfeld <[email protected]>
  • Loading branch information
omertuc committed Feb 10, 2025
1 parent 69264e0 commit d4afa07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions system-reinstall-bootc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ pub(crate) mod users;

const ROOT_KEY_MOUNT_POINT: &str = "/bootc_authorized_ssh_keys/root";

const NO_SSH_PROMPT: &str = "None of the users on this system found have authorized SSH keys, if
your image doesn't use cloud-init or other means to set up users, you may not be able to log in
after reinstalling. Do you want to continue?";

fn run() -> Result<()> {
bootc_utils::initialize_tracing();
tracing::trace!("starting {}", env!("CARGO_PKG_NAME"));
Expand All @@ -20,8 +24,13 @@ fn run() -> Result<()> {

let config = config::ReinstallConfig::load().context("loading config")?;

let mut reinstall_podman_command =
podman::command(&config.bootc_image, &prompt::get_root_key()?);
let root_key = &prompt::get_root_key()?;

if root_key.is_none() {
prompt::ask_yes_no(NO_SSH_PROMPT, false)?;
}

let mut reinstall_podman_command = podman::command(&config.bootc_image, root_key);

println!();

Expand Down

0 comments on commit d4afa07

Please sign in to comment.