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

Add metal user and SSH Keypair during Discovery boot #219

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

afritzler
Copy link
Member

@afritzler afritzler commented Jan 16, 2025

Proposed Changes

This PR introduces a feature to create a metal user with a corresponding SSH keypair which is stored as a Secret alongside the discovery ServerBootConfiguration. The Secret is named
<serverbootconfig.name-ssh>. This allows an administrator to use the private key in this Secret to SSH into the Server in case something went wrong when running the metalprobe agent.

The Secret is being removed again once the ServerBootConfiguration for the discovery boot has been removed after a successful Server onboarding.

Fixes #217

This PR introduces a feature to create a `metal` user with corresponding
SSH keypairs which are stored as a `Secret` alongside the discovery
`ServerBootConfiguration`. The `Secret` is named
`<serverbootconfig.name-ssh>`. This allows an administrator to use the
private key in this `Secret` to SSH into the `Server` in case something
went wrong when running the `metalprobe` agent.
@github-actions github-actions bot added size/L enhancement New feature or request labels Jan 16, 2025
Copy link
Contributor

@Nuckal777 Nuckal777 left a comment

Choose a reason for hiding this comment

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

Thanks. Should the secret be deleted when transitioning away from the Discovery phase?

internal/ignition/default.go Outdated Show resolved Hide resolved
internal/controller/server_controller.go Outdated Show resolved Hide resolved
internal/controller/server_controller.go Outdated Show resolved Hide resolved
Image: r.ProbeImage,
Flags: flags,
func generateSSHKeyPairs() ([]byte, []byte, error) {
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we consider ed25519 or 4096-bit keys?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can make this configurable later. RSA was easier because there helper method to validate the correctness of the key.

@afritzler afritzler force-pushed the enh/discovery-ssh branch 2 times, most recently from 5d9e762 to 8173057 Compare January 16, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate and inject admin SSH key during Discovery phase
2 participants