Modprobe: ERROR: could not insert 'v4l2loopback': Key was rejected by service

I am trying to use OBS Studio Virtual camera, so I installed v4l2loopback and rebooted.

When I try to start the virtual camera I was asked for the password but the virtual camera wasn’t activated.

Then I tried running sudo modprobe v4l2loopback and got the error in the topic heading.

Any clues on how to xolve this issue?

You most likely have Secure Boot enabled. As the module is not signed, the kernel refuses to load it.

You have two options:

  1. disable Secure Boot
  2. self-sign the module
1 Like

I used this on Ubuntu and I didn’t have to do either of the two. I do have Secure Boot enabled and I chose Fedora because it is one of the very few distros that work with it enabled.
I remember having to install a package named v4l2loopback-dkms on Ubuntu. Is there an equivalent on Fedora? I search for a package with the same name but to no avail.

I followed this tutorial and managed to make it work. I hope it doesn’t break when the kernel is updated.
I wouldn’t have managed alone for sure: it is beyond my current linux skill set.

1 Like

As I suspected, every kernel upgrade breaks the module signature. Is there a way to automate the module signing after each kernel upgrade?

It seems support for secure boot was added to akmods in a October 2021 commit. (See also recent github issue comment.)

Instructions here: /usr/share/doc/akmods/README.secureboot.

Here’s two screenshots showing the screens that will present themselves the next time you reboot to enroll the public key in MOK (Machine Owner Key key management system) :

f4e266a3f8595fb7e5613669cb7aa831e4ed1c23.jpeg

83b6ec7376a776e31effcccee64fdb3156626a83.jpeg

Excerpt from journal shows that the v4l2loopback module was successfully built and installed:

Sep 06 09:20:48 hx90 systemd[1]: Starting akmods@5.19.7-200.fc36.x86_64.service - Builds and install new kmods from akmod for a given kernel...
Sep 06 09:20:48 hx90 systemd-inhibit[35589]: Checking kmods exist for 5.19.7-200.fc36.x86_64[  OK  ]
[...]
Sep 06 09:20:59 hx90 systemd-inhibit[35589]: Building and installing v4l2loopback-kmod[  OK  ]
Sep 06 09:20:59 hx90 systemd[1]: Finished akmods@5.19.7-200.fc36.x86_64.service - Builds and install new kmods from akmod for a given kernel.

Check that the v4l2loopback module was loaded

$ lsmod | grep -F v4l2loopback
v4l2loopback           45056  0
videodev              274432  4 videobuf2_v4l2,v4l2loopback,uvcvideo,videobuf2_common

If necessary, load it manually:

sudo modprobe v4l2loopback

To unload:

sudo modprobe -r v4l2loopback
2 Likes

I followed this procedure but now I’m getting this error in the logs:
Failed to insert module 'v4l2loopback': Key was rejected by service
What am I doing wrong?
I had manually installed and self-signed v4l2loopback which worked until the kernel was updated.
I didn’t uninstall this manual version and don’t know how to.

Disabling Secure Boot solved the problem for me. There probably is a way to do it with secure boot too but I am lacking the energy to do this.
I’d really rather have a userspace method to pipe video around applications.

I don’t want to disable secure boot.

A third party app that the user compiles which uses kernel modules would need recompiled (in a way that signs the module) with every kernel update while using secure boot. The alternative is to disable secure boot or uninstall the app.

Somehow this was done automatically with Ubuntu. No need for manual compilation of packages, etc.

It is this and the fact that I cannot use the Dell fingerprint sensor that I miss from Ubuntu. For all the rest, I prefer Fedora.

It can be built automatically with DKMS.
But you need to enroll the certificate that DKMS is using by default to sign the module:

sudo mokutil -i /var/lib/dkms/mok.pub

If the issue persists, clean old versions of the module:

sudo rm -f -R /usr/lib/modules/*/extra/v4l2loopback* \
/usr/src/v4l2loopback* /var/lib/dkms/v4l2loopback*

Set up v4l2loopback with DKMS:

sudo dnf install git dkms kernel-devel openssl
sudo git clone https://github.com/umlaeute/v4l2loopback.git \
/usr/src/v4l2loopback-git
sudo dkms add v4l2loopback/git
sudo systemctl restart dkms.service
sudo tee /etc/modules-load.d/v4l2loopback.conf << EOF > /dev/null
v4l2loopback
EOF
sudo systemctl restart systemd-modules-load.service

Form enrolling request:

MOK_PASSWD="fedora"
sudo mokutil -i /var/lib/dkms/mok.pub << EOI
${MOK_PASSWD}
${MOK_PASSWD}
EOI

This works for me just fine.

OBS Studio stopped shipping as RPM or Deb packages and now their official package is a Flatpak. I switched the the Flatpak and everything, including Virtual Camera, works out of the box.

1 Like

The error the OP has is due to secure boot and having a locked down linux kernel (linux kernel lockdown turns on automatically with secure boot and helps prevent your kernel from unwanted modifications). So, your option as stated by Damian Ludwig is to either disable Secure Boot or self-sign the module yourself. Turning off secure boot would happen in your BIOS, but if you want the alternative then here’s a link to the official Fedora documentation on how to self sign a module: Working with Kernel Modules :: Fedora Docs