Skip to content

Commit 0fc7830

Browse files
authored
Merge pull request #1092 from omertuc/warnssh
reinstall: warn if no users with authorized ssh keys are found
2 parents 155c5e2 + 05da485 commit 0fc7830

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

system-reinstall-bootc/src/main.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ pub(crate) mod users;
1111

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

14+
const NO_SSH_PROMPT: &str = "None of the users on this system found have authorized SSH keys, if
15+
your image doesn't use cloud-init or other means to set up users, you may not be able to log in
16+
after reinstalling. Do you want to continue?";
17+
1418
fn run() -> Result<()> {
1519
bootc_utils::initialize_tracing();
1620
tracing::trace!("starting {}", env!("CARGO_PKG_NAME"));
@@ -20,8 +24,13 @@ fn run() -> Result<()> {
2024

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

23-
let mut reinstall_podman_command =
24-
podman::command(&config.bootc_image, &prompt::get_root_key()?);
27+
let root_key = &prompt::get_root_key()?;
28+
29+
if root_key.is_none() && !prompt::ask_yes_no(NO_SSH_PROMPT, false)? {
30+
return Ok(());
31+
}
32+
33+
let mut reinstall_podman_command = podman::command(&config.bootc_image, root_key);
2534

2635
println!();
2736

0 commit comments

Comments
 (0)