Skip to content

Instantly share code, notes, and snippets.

@kurtbahartr
Last active April 23, 2025 11:46
Show Gist options
  • Save kurtbahartr/f31e1d2488b05f6947f84de6bdca469e to your computer and use it in GitHub Desktop.
Save kurtbahartr/f31e1d2488b05f6947f84de6bdca469e to your computer and use it in GitHub Desktop.
Sign things in Ubuntu using MOK certificates from shim-signed
#!/bin/bash
if [[ "$@" =~ ^-h$ ]] || [[ "$@" =~ ^-h\ ]] || [[ "$@" =~ \ -h\ ]] || [[ "$@" =~ \ -h$ ]]; then
echo "usage: sign-mok.sh /path/to/module.ko ..."
echo ""
echo "kmodsign usually accepts only one module per invocation."
echo "This script works with multiple modules because we work around this limitation with a for loop."
exit
fi
if [ "$2" != "" ]; then
echo "kmodsign usually accepts only one module per invocation."
echo "This script works with multiple modules because we work around this limitation with a for loop."
fi
for module in $@; do
echo "Signing $module..."
[ -f "$module" ] && sudo kmodsign sha512 /var/lib/shim-signed/mok/MOK.{priv,der} $module && echo "Signed $module." || echo "Could not sign $module."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment