-
Notifications
You must be signed in to change notification settings - Fork 192
system-reinstall-bootc: SSH key handling via cloud-init detection #2163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,20 +73,36 @@ fn run() -> Result<()> { | |
| let has_clean = podman::bootc_has_clean(&opts.image)?; | ||
| spinner.finish_and_clear(); | ||
|
|
||
| let ssh_key_file = tempfile::NamedTempFile::new()?; | ||
| let ssh_key_file_path = ssh_key_file | ||
| .path() | ||
| .to_str() | ||
| .ok_or_else(|| anyhow::anyhow!("unable to create authorized_key temp file"))?; | ||
| let mut _ssh_key_tempfile = None; | ||
| let mut ssh_key_file_path = None; | ||
|
|
||
| if podman::image_has_cloud_init(&opts.image)? { | ||
| let host_root_keys = std::path::Path::new("/root/.ssh/authorized_keys"); | ||
| if host_root_keys.exists() { | ||
|
Comment on lines
+80
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The automatic inheritance logic only checks for keys in |
||
| println!("Detected cloud-init and host keys. Inheriting keys automatically."); | ||
| ssh_key_file_path = Some(host_root_keys.to_string_lossy().into_owned()); | ||
| } else { | ||
| println!("Detected cloud-init. Proceeding without host key inheritance."); | ||
| } | ||
| } else { | ||
| let file = tempfile::NamedTempFile::new()?; | ||
| let file_path = file | ||
| .path() | ||
| .to_str() | ||
| .ok_or_else(|| anyhow::anyhow!("unable to create authorized_key temp file"))?; | ||
|
|
||
| tracing::trace!("ssh_key_file_path: {}", file_path); | ||
|
|
||
| tracing::trace!("ssh_key_file_path: {}", ssh_key_file_path); | ||
| prompt::get_ssh_keys(file_path)?; | ||
|
|
||
| prompt::get_ssh_keys(ssh_key_file_path)?; | ||
| ssh_key_file_path = Some(file_path.to_string()); | ||
| _ssh_key_tempfile = Some(file); | ||
| } | ||
|
|
||
| prompt::mount_warning()?; | ||
|
|
||
| let mut reinstall_podman_command = | ||
| podman::reinstall_command(&opts, ssh_key_file_path, has_clean)?; | ||
| podman::reinstall_command(&opts, ssh_key_file_path.as_deref(), has_clean)?; | ||
|
|
||
| println!(); | ||
| println!("Going to run command:"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
podman::image_has_cloud_initcheck involves running a container, which can take a few seconds. It should be performed while the spinner is active to provide better feedback to the user and avoid a perceived hang in the UI.