-
-
Notifications
You must be signed in to change notification settings - Fork 152
Add microvm.credentialFiles for passing credentials to guests
#337
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 microvm.credentialFiles for passing credentials to guests
#337
Conversation
|
NixCI is ready to run on this PR. |
|
That looks well to me. Are you going to try adding the other hypervisors? Where not supported, please add |
Yes I will attempt to implement it in the runners for the other hypervisors, and for those that I can't I'll add an assert. I'll also update the docs. I'd like to implement a test for this too. Could you point me to where in FYI this is how I am able to take advantage of the credential, by setting the SSH host key (which also lets me bootstrap my sops-nix in the guest). # this is part of the guest vms nixos config
microvm.credentialFiles = {
"SSH_HOST_KEY" = "/run/secrets/mymicrovm_sops_ssh_key"; # This file must exist on the host, since I use imperative vms, I have to make it manually.
};
systemd.services.sshd = {
serviceConfig = {
ImportCredential = "SSH_HOST_KEY";
};
preStart = ''
mkdir -p /etc/ssh
cat $CREDENTIALS_DIRECTORY/SSH_HOST_KEY > /etc/ssh/ssh_host_ed25519_key
chmod 0600 /etc/ssh/ssh_host_ed25519_key
'';
};I got ill, so it might be until next week before I'm able to return to these PRs. |
|
The top of Get well soon, and don't feel stressed from open tickets! |
|
Is there a workaround currently (until this gets implemented) for passing sops-nix secrets through to the vm? I tried creating a shared directory by mounting This is what I tried: # ... other config
microvm.shares = [
# nix read only store ...
{
source = "/run/secrets-for-users";
mountPoint = "/run/secrets-for-users";
tag = "secrets";
proto = "9p";
}
]; |
|
@Sveske-Juice We use sops-nix with per-VM keys. |
So if I am understanding right. If this PR gets merged. We would be able to decrypt the secrets via the VM's key. So this feature would make it possible to bootstrap the VM with a valid SSH host key that can be used to decrypt the secrets? EDIT: |
Ok I am well again and have some time available for FOSS contributions :) I'm trying to just get my test running (see the commit I just pushed), it won't work yet. But when i run I've also tried I've also tried
Any tips? |
66a6e8e to
6cccd91
Compare
cae0066 to
d522c4a
Compare
d522c4a to
960755b
Compare
|
@astro Picking this one back up, I've rebased with FWIW I've been using this patch for many months now, and it makes bootstrapping sops secrets (and therefore sshd secrets) into a nixos guest a breeze! |
microvm.credentialFiles for passing credentials to guestsmicrovm.credentialFiles for passing credentials to guests
We still need to add this, otherwise LGTM |
066ca58 to
1279ef8
Compare
Done! Also fixed the spelling mistake caught by the CI :) The deadnix workflow can't pass. It is configured to expect the source branch and the target branch in the same repo (this repo), but the branch is in my fork. BTW I have an open PR to cloud-hypervisor cloud-hypervisor/cloud-hypervisor#7198 that will add a feature needed to be able to safely implement |
I hope I fixed that on main. If you rebase or in the next PR it should be fixed. Also, we caught a merge conflict that needs rebasing. |
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.
otherwise LGTM
This commit implements `microvm.credentialFiles` a mechanism for passing credentials into guest vms from the host. Currently only support for qemu is implemented as I want to test the waters to see if you're interested in this feature, Astro. In addition to qmeu cloud-hypervisor can be supported via smbios. But it depends on [this feature being added](cloud-hypervisor/cloud-hypervisor#6951 (comment)), and also microvm-nix#336 being merged to microvm.nix cloud-hypervisor could be supported immediately, but then the secrets would be visible in the ps output. A cursory code search shows that the following additional hypervisors could be supported: - crosvm: via fw_cfg, or smbios - alioth: via fw_cfg - stratovirt: via fw_cfg (maybe smbios) kvmtool and firecracker both seem like they cannot be supported. Related: - microvm-nix#259 - microvm-nix#52
cc960e3 to
bb97831
Compare
|
force pushed to resolve merge conflicts, and also resolved the feedback above. |
This commit implements
microvm.credentialFilesa mechanism for passingcredentials into guest vms from the host.
Currently only support for qemu is implemented as I want to test the waters to
see if you're interested in this feature, Astro.
In addition to qmeu, cloud-hypervisor can be supported via smbios. But it depends
on this feature being added, and also #336 being merged to microvm.nix
cloud-hypervisor could be supported immediately, but then the secrets would be
visible in the ps output.
A cursory code search shows that the following additional hypervisors could be
supported:
kvmtool and firecracker both seem like they cannot be supported.
Related: