sudo apt-get update && sudo apt upgrade -y
sudo apt-get install make build-essential gcc git jq chrony -y
UBUNTUVERSION=$(lsb_release -r -s | cut -d '.' -f 1)
PSW_PACKAGES='libsgx-enclave-common libsgx-urts sgx-aesm-service libsgx-uae-service autoconf libtool make gcc'
if (($UBUNTUVERSION < 16)); then
echo "Your version of Ubuntu is not supported. Must have Ubuntu 16.04 and up. Aborting installation script..."
elif (($UBUNTUVERSION == 16)); then
elif (($UBUNTUVERSION == 18)); then
elif (($UBUNTUVERSION == 20)); then
echo "\n\n###############################################"
echo "##### Installing Intel SGX driver #####"
echo "###############################################\n\n"
if (($UBUNTUVERSION == 16)); then
# Ubuntu 16 was deprecated by the latest Intel SGX drivers
wget "https://download.01.org/intel-sgx/sgx-linux/2.13/distro/${OS}/sgx_linux_x64_driver_2.11.0_0373e2e.bin"
wget "https://download.01.org/intel-sgx/sgx-linux/2.14/distro/${OS}/sgx_linux_x64_driver_2.11.0_2d2b795.bin"
# Make the driver installer executable
chmod +x ./sgx_linux_x64_driver_*.bin
sudo ./sgx_linux_x64_driver_*.bin
# Remount /dev as exec, also at system startup
sudo tee /etc/systemd/system/remount-dev-exec.service >/dev/null <<EOF
Description=Remount /dev as exec to allow AESM service to boot and load enclaves into SGX
ExecStart=/bin/mount -o remount,exec /dev
WantedBy=multi-user.target
sudo systemctl enable remount-dev-exec
sudo systemctl start remount-dev-exec
echo "\n\n###############################################"
echo "##### Installing Intel SGX PSW #####"
echo "###############################################\n\n"
echo "deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu $DISTRO main" |
sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key |
if (($UBUNTUVERSION > 18)); then
sudo apt install -y gdebi
# Install all the additional necessary dependencies (besides the driver and the SDK)
# for building a rust enclave
wget -O /tmp/libprotobuf30_3.19.4-1_amd64.deb https://engfilestorage.blob.core.windows.net/filestorage/libprotobuf30_3.19.4-1_amd64.deb
yes | sudo gdebi /tmp/libprotobuf30_3.19.4-1_amd64.deb
PSW_PACKAGES+=' libprotobuf-dev'
sudo apt install -y $PSW_PACKAGES