In this guide, we will be exploring how to install and run SGX-LKL-OE, a specialized project designed to execute existing unmodified Linux binaries inside Intel SGX enclaves. We will cover the installation process, building from source, and running applications, while also including troubleshooting tips along the way.
What is SGX-LKL-OE?
SGX-LKL is a project aimed at providing a secure enclave environment where complex applications like TensorFlow, PyTorch, and Java runtimes can operate without needing modifications or relying heavily on an untrusted host OS. This project is still under active development, so expect it to be experimental and possibly encounter various bugs.
Installing SGX-LKL-OE
SGX-LKL-OE is distributed via a Debian package format. Here’s how to get it running:
1. Add Repository and Install
- For development releases, run:
echo deb [trusted=yes] https://clcpackages.blob.core.windows.net/apt-dev/1fa5fb889b8efa6ea07354c3b54903f7 . | sudo tee /etc/apt/sources.list.d/azure-clc.list - For stable releases, run:
echo deb [trusted=yes] https://clcpackages.blob.core.windows.net/apt/1fa5fb889b8efa6ea07354c3b54903f7 . | sudo tee /etc/apt/sources.list.d/azure-clc.list - To install, use:
sudo apt updatesudo apt install sgx-lkl-debug
2. Setting up Environment Variables
To make SGX-LKL commands accessible from any directory, you need to add it to the PATH environment variable:
PATH=$PATH:/opt/sgx-lkl/bin
3. Configure the Host Environment
Run the following command to set up the host environment after every reboot:
sgx-lkl-setup
Building SGX-LKL-OE from Source
Building from the source gives you more control and often allows you to access the latest features:
1. Install Dependencies
sudo apt-get install make gcc g++ bc python xutils-dev bison flex libgcrypt20-dev libjson-c-dev automake autopoint autoconf pkgconf libtool libcurl4-openssl-dev libprotobuf-dev libprotobuf-c-dev protobuf-compiler protobuf-c-compiler libssl-dev
2. Clone the SGX-LKL Repository
git clone --branch oe_port --recursive https://github.com/lsds/sgx-lkl.git
cd sgx-lkl
3. Build SGX-LKL
There are different build types based on your needs:
- Debug build (non-optimized):
make DEBUG=true - Optimized build (production-ready):
make
Running Applications with SGX-LKL
Now that you’ve set up SGX-LKL-OE, you can begin running applications inside enclaves. Here’s how:
1. Prepare Your Application
Your application should be part of a Linux disk image, preferably based on Alpine Linux with musl libc as the standard library.
2. Using Sample Applications
The SGX-LKL source includes example applications. To run them, navigate to the samples directory and execute:
make run-hw
Or for software mode without SGX support:
make run-sw
3. Create SGX-LKL Disk Images
Utilize the sgx-lkl-disk tool to create, check, and mount disk images. For example, to create a disk image with an Alpine application:
sgx-lkl-disk create --size=50M --alpine=redis sgxlkl-disk.img
Troubleshooting
If you encounter issues during installation or while running applications, consider the following tips:
- Make sure you are using the compatible Linux distribution as stated in the documentation.
- Ensure that your Linux kernel supports the required user-space FSGSBASE instructions for optimal performance.
- If you experience permissions issues with disk images, remember to use superuser rights where necessary.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
By following the above steps, you should be well on your way to harnessing the power of SGX-LKL-OE for executing your Linux applications securely. If you find yourself in a bind, don’t hesitate to refer back to the documentation or community forums.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

