Skip to content

Instantly share code, notes, and snippets.

@bboozzoo
Created April 26, 2022 11:52
Show Gist options
  • Save bboozzoo/53d8d07be5ec01f7e1b693b33831eba5 to your computer and use it in GitHub Desktop.
Save bboozzoo/53d8d07be5ec01f7e1b693b33831eba5 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
if [ "$#" -ne 2 ] || [ "$1" = "--help" ]; then
echo "usage: $0 <key-name> <system-user-assertion-json>"
exit 1
fi
# sign the assertion
sysUser=$(snap sign -k $1 < $2)
accountID=$(echo "$sysUser" | grep -Po "authority-id:\s+\K.*")
signingKeySha=$(echo "$sysUser" | grep -Po "sign-key-sha3-384:\s+\K.*" )
{
# get the account key assertion from the store
snap known --remote account "account-id=$accountID"
echo ""
# get the signing account-key assertion from the store
snap known --remote account-key "public-key-sha3-384=$signingKeySha"
echo ""
echo "$sysUser"
} > auto-import.assert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment