I followed the 'Debian-based Linux distributions' guide on the VirtualBox website.

After sudo apt install virtualbox-5.2 I got the error:

vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.

dmesg: Loading of unsigned modules is restricted; see man kernel_lockdown.7.

How can I fix this?

I read something about secureboot but I don't want to disable it.

Do I have to sign the VirtualBox module (how? add custom sign key?) or is there another way?

I'm running Kubuntu 18.04 Kernel 4.15.0-23-generic.

EDIT

After following this guide https://stegard.net/2016/10/virtualbox-secure-boot-ubuntu-fail/ and executing sudo modprobe vboxdrv I got the error modprobe: ERROR: could not insert 'vboxdrv': Required key not available. With modinfo vboxdrv I see:

filename:       /lib/modules/4.15.0-23-generic/misc/vboxdrv.ko
version:        5.2.12 r122591 (0x00290001)
license:        GPL
description:    Oracle VM VirtualBox Support Driver
author:         Oracle Corporation
srcversion:     63368184ED096B3022FD087
depends:        
retpoline:      Y
name:           vboxdrv
vermagic:       4.15.0-23-generic SMP mod_unload 
signat:         PKCS#7
signer:         
sig_key:        
sig_hashalgo:   md4

So it looks like it's not signed right? Whats wrong with this? I tried to sign it manually with /usr/src/linux-headers-4.15.0-23-generic/scripts/sign-file sha256 ./MOK.priv ./MOK.der /lib/modules/4.15.0-23-generic/misc/vboxdrv.ko with the same result.

marked as duplicate by Panther, Arronical, Pilot6, user535733, Fabby Jun 13 at 21:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.