Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
cgwalters merged 2 commits into
bootc-dev:mainfrom
ckyrouac:reinstall-ssh
Feb 27, 2025
Merged

Smarter ssh authorized key search for system-reinstall-bootc#1146
cgwalters merged 2 commits into
bootc-dev:mainfrom
ckyrouac:reinstall-ssh

Conversation

@ckyrouac

Copy link
Copy Markdown
Collaborator

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
Comment thread system-reinstall-bootc/src/users.rs Outdated
Comment thread system-reinstall-bootc/src/users.rs Outdated
This is prep for running authorizedkeyscommand to collect the user's
authorized keys.

Signed-off-by: ckyrouac <[email protected]>
Comment thread system-reinstall-bootc/src/prompt.rs Outdated
Comment thread system-reinstall-bootc/src/main.rs Outdated
Comment thread system-reinstall-bootc/src/prompt.rs Outdated
Comment thread system-reinstall-bootc/src/prompt.rs
Comment thread system-reinstall-bootc/src/users.rs Outdated

// 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
Copy Markdown
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)

Comment thread system-reinstall-bootc/src/users.rs
Comment thread system-reinstall-bootc/src/users.rs
Comment thread system-reinstall-bootc/src/users.rs Outdated
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 <[email protected]>
@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
Copy Markdown
Collaborator Author

This is ready for a final review

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Collaborator

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"

serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
serde_yaml = "0.9.22"
tempfile = "3.10.1"

Copy link
Copy Markdown
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 }

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
Copy Markdown
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!

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