Skip to content
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

Smarter ssh authorized key search for system-reinstall-bootc #1146

Merged
merged 2 commits into from
Feb 27, 2025

Conversation

ckyrouac
Copy link
Contributor

Pushing this branch early for visibility. The first commit just parses the sshd -T output into a struct.

@github-actions github-actions bot added the area/system-reinstall-bootc Issues related to system-reinstall-botoc label Feb 26, 2025
This is prep for running authorizedkeyscommand to collect the user's
authorized keys.

Signed-off-by: ckyrouac <ckyrouac@redhat.com>

// Safety: The UID should be valid because we got it from uzers
#[allow(unsafe_code)]
let user_uid = unsafe { Uid::from_raw(user.uid()) };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is OK for now but I think per previous discussion we actually don't need to change uid for this, we can just use cap-std)

Prior to this, the prompt to select users other that root would result
in an error. Now, all ssh keys will be gathered into a single file
and passed to bootc install to-existing-root --root-ssh-authorized-keys.

Signed-off-by: ckyrouac <ckyrouac@redhat.com>
@ckyrouac ckyrouac changed the title WIP: Smarter ssh authorized key search for system-reinstall-bootc Smarter ssh authorized key search for system-reinstall-bootc Feb 27, 2025
@ckyrouac
Copy link
Contributor Author

This is ready for a final review

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's ship it - I had two totally minor things that can just be rolled into a subsequent PR.

I'll try to use the prefix "nit-for-followup:" to mean "next time you (or someone else) does a PR let's consider fixing this then"

@@ -24,6 +24,7 @@ rustix = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
serde_yaml = "0.9.22"
tempfile = "3.10.1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-for-followup: Let's use { workspace = true }

@@ -10,7 +7,9 @@ const NO_SSH_PROMPT: &str = "None of the users on this system found have authori

fn prompt_single_user(user: &crate::users::UserKeys) -> Result<Vec<&crate::users::UserKeys>> {
let prompt = format!(
"Found only one user ({}) with {} SSH authorized keys. Would you like to import it and its keys to the system?",
"Found only one user ({}) with {} SSH authorized keys.\n\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion-for-followup: This would be more readable with indoc!

@cgwalters cgwalters enabled auto-merge February 27, 2025 16:17
@cgwalters cgwalters merged commit 55303ae into containers:main Feb 27, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/system-reinstall-bootc Issues related to system-reinstall-botoc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants