我在启用 uefi 安全启动的情况下无法让 virtualbox5.1 在 ubuntu 16.10 上运行,这要从我对 vagrant 的自学开始,然后进一步学习 :)。所以我希望有人能帮我找出问题所在或给我指明正确的方向。
我在网上进行了大量研究,并找到了这个程序,但它对我来说不起作用,当我执行“sudo modinfo vboxdrv”时,我缺少签名信息。
我将显示我认为相关的输出。如果您需要更多信息,请随时告诉我:
uname -r
4.8.0-26-generic
dpkg -S sign-file
linux-headers-4.8.0-22-generic: /usr/src/linux-headers-4.8.0-22-generic/scripts/.sign-file.cmd
linux-headers-4.8.0-26-generic: /usr/src/linux-headers-4.8.0-26-generic/scripts/.sign-file.cmd
linux-headers-4.8.0-26: /usr/src/linux-headers-4.8.0-26/scripts/sign-file.c
linux-headers-4.8.0-22-generic: /usr/src/linux-headers-4.8.0-22-generic/scripts/sign-file
linux-headers-4.8.0-26-generic: /usr/src/linux-headers-4.8.0-26-generic/scripts/sign-file
linux-headers-4.8.0-22: /usr/src/linux-headers-4.8.0-22/scripts/sign-file.c
linux-headers-4.8.0-22-generic: /usr/src/linux-headers-4.8.0-22-generic/scripts/sign-file.c
linux-headers-4.8.0-26-generic: /usr/src/linux-headers-4.8.0-26-generic/scripts/sign-file.c
cd .ssh
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -days 36500 -subj "/[email protected]"
“输入我的密码两次”,因为我省略了-nodes(额外的安全性;])
chmod 600 MOK.priv
export KBUILD_SIGN_PIN=”p4$$w<>rD” (not the real password off-course:])
-rw------- 1 username username 1834 Okt 21 14:44 MOK.priv
-rw-r--r-- 1 username username 837 Okt 21 14:44 MOK.der
-rwx------ 1 username username 1113 Okt 21 15:20 signscript
for f in $(dirname $(modinfo -n vboxdrv))/*.ko; do echo "Signing $f"; sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $f; done
Signing /lib/modules/4.8.0-26-generic/misc/vboxdrv.ko
At main.c:161:
- SSL error:0907B068:PEM routines:PEM_READ_BIO_PRIVATEKEY:bad password read: pem_pkey.c:117
sign-file: ./MOK.priv: Success
Signing /lib/modules/4.8.0-26-generic/misc/vboxnetadp.ko
At main.c:161:
- SSL error:0907B068:PEM routines:PEM_READ_BIO_PRIVATEKEY:bad password read: pem_pkey.c:117
sign-file: ./MOK.priv: Success
Signing /lib/modules/4.8.0-26-generic/misc/vboxnetflt.ko
At main.c:161:
- SSL error:0907B068:PEM routines:PEM_READ_BIO_PRIVATEKEY:bad password read: pem_pkey.c:117
sign-file: ./MOK.priv: Success
Signing /lib/modules/4.8.0-26-generic/misc/vboxpci.ko
At main.c:161:
- SSL error:0907B068:PEM routines:PEM_READ_BIO_PRIVATEKEY:bad password read: pem_pkey.c:117
sign-file: ./MOK.priv: Success
sudo mokutil --import MOK.der
我重新启动计算机并成功注册证书。当我验证 vboxdrv 是否已签名时:
sudo modinfo vboxdrv
filename: /lib/modules/4.8.0-26-generic/misc/vboxdrv.ko
version: 5.1.8 r111374 (0x00280000)
license: GPL
description: Oracle VM VirtualBox Support Driver
author: Oracle Corporation
srcversion: 0194E56703167BB8828186F
depends: jjjjjjjjjjjjjjjjj
vermagic: 4.8.0-26-generic SMP mod_unload modversions
parm: force_async_tsc:force the asynchronous TSC mode (int)
该模块未签名,因为我缺少此输出中的信息:
signer: something
sig_key: 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11
sig_hashalgo: sha256
为了确保我没有犯错误,我使用了这个脚本: https://github.com/Majal/maj-scripts/blob/master/vboxsign
#!/bin/bash
# Sign and load VirtualBox modules
# Run as root
[ "`whoami`" = root ] || exec sudo "$0" "$@"
# Set working directory
dir=/home/username/.ssh
cd $dir
# (Optional) Setting env KBUILD_SIGN_PIN for encrypted keys
printf "Please enter key passphrase (leave blank if not needed): "; read -s
export KBUILD_SIGN_PIN="$REPLY"
# (Optional) Decrypt private key. To initially encrypt, run `gpg -c MOK.priv` then shred MOK.priv
#gpg -d --batch --passphrase-file /owned/by/root/.pass MOK.priv.gpg > MOK.priv
echo
# Sign and load modules
for module in vboxdrv vboxnetflt vboxnetadp vboxpci; do
[ "`hexdump -e '"%_p"' $(modinfo -n $module) | tail | grep signature`" ] && echo -e "\e[93mModule $module is already signed. Skipping.\e[0m" || /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n $module)
printf "$module: "
echo `hexdump -e '"%_p"' $(modinfo -n $module) | tail | grep signature`
modprobe $module && echo -e "\e[92m$module successfully loaded\e[0m" || echo -e "\e[91mFailed to load $module\e[0m"
done
# (Optional) Shred private key
echo
#shred -vfuz MOK.priv
不幸的是没有成功,我甚至收到 SSL 错误,但签名文件脚本告诉我它已成功签名“签名文件:./MOK.priv:成功”
At main.c:161:
- SSL error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt: evp_enc.c:529
- SSL error:23077074:PKCS12 routines:PKCS12_pbe_crypt:pkcs12 cipherfinal error: p12_decr.c:108
- SSL error:2306A075:PKCS12 routines:PKCS12_item_decrypt_d2i:pkcs12 pbe crypt error: p12_decr.c:139
- SSL error:0907B00D:PEM routines:PEM_READ_BIO_PRIVATEKEY:ASN1 lib: pem_pkey.c:141
sign-file: ./MOK.priv: Success
vboxpci:
modprobe: ERROR: could not insert 'vboxpci': Required key not available
Failed to load vboxpci
当我做:
sudo /sbin/vboxconfig
Created symlink /etc/systemd/system/multi-user.target.wants/vboxdrv.service → /lib/systemd/system/vboxdrv.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxballoonctrl-service.service → /lib/systemd/system/vboxballoonctrl-service.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxautostart-service.service → /lib/systemd/system/vboxautostart-service.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxweb-service.service → /lib/systemd/system/vboxweb-service.service.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
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.
但是“sudo dmesg | grep vbox”是空的
我知道信息量很大,但我希望有人能帮助我,或者给我指明正确的方向。
这是一个全新安装,所以如果需要的话,我可以尝试一下:)
答案1
您提供的输出显示每个模块的签名过程中出现密码错误:
Signing /lib/modules/4.8.0-26-generic/misc/vboxdrv.ko
At main.c:161:
- SSL error:0907B068:PEM routines:PEM_READ_BIO_PRIVATEKEY:bad password read: pem_pkey.c:117
问题是密码永远无法到达 OpenSSL。您可以使用当前用户的环境变量指定密码:
export KBUILD_SIGN_PIN=”p4$$w<>rD”
但是当您运行下面几行签名脚本时,您使用 sudo 在根环境而不是用户环境中运行它:
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $f
该脚本以root身份运行,而KBUILD_SIGN_PIN变量不在root环境中,因此脚本无法访问KBUILD_SIGN_PIN。
可以通过将环境变量放在 sudo 后面来解决此问题,以确保它在根环境中设置:
sudo KBUILD_SIGN_PIN="p4$$w<>rD" /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $f
答案2
最简单的解决方案是禁用安全启动。可以使用自己的密钥对内核模块进行签名,然后注册该密钥,但我不知道该过程的细节。
答案3
当您将 MOK 添加到垫片中时
mokutil --import MOK.der
- 记下您提供的密码。
- 重新启动并按照菜单,使用此密码注册密钥
重启后密钥注册后,MOK 即可用于签署 vbox 模块。