Virtual Debian Environment¶
You can create a complete Debian environment that runs within Android through the FIRERPA add-on module, similar to what Termux or androdeb provide. You can use apt to install software and compile code in this environment, and you can also compile and use BPF-related programs here. It is a near-complete Linux environment running on an Android device.
Hint
This Debian environment includes only essential packages, you need to use apt to install common commands like git, python3 yourself.
Installing the Environment¶
You can find lamda-mod-debian-arm64-v8a.tar.gz on the project's release page (please download the package matching your device's architecture). After downloading, open Remote Desktop, drag and drop the downloaded file to upload it to the device (we assume you haven't changed the Remote Desktop file upload directory), then perform the following installation steps. This installation does not need to be repeated.
Hint
Files uploaded through Remote Desktop are placed in the ~/uploads directory by default.
tar -C ~/modules -xzf ~/uploads/lamda-mod-debian-arm64-v8a.tar.gz
After executing the command, the installation is complete. Next, we'll explain how to enter the environment.
Entering the Environment¶
After installing the file system of the environment, we can execute a command to enter the virtual Debian environment. The Debian environment has been installed to ~/modules/debian. You can enter the Debian interactive terminal with the following command:
debian /bin/bash
If you only need to execute a single command, such as the id command, you can use it like this:
debian /bin/bash -c id
Attention
Only one instance can enter the virtual environment at a time. If you keep the session alive after running debian /bin/bash, attempting to run the command again in another terminal will return an error. Please exit the previous debian session before trying again.
Advanced Usage¶
We will introduce a simple advanced usage. Once done, you can run an SSH service or Python scripts in the environment, free from the session limit. First, execute the following command to enter the virtual environment.
debian /bin/bash
Now you should be inside the virtual environment. Follow along and execute the commands below.
apt update
apt install -y openssh-server procps python3 python3-pip python3-dev
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
echo 'StrictModes no' >> /etc/ssh/sshd_config
mkdir -p /run/sshd
# change root password
echo root:lamda|chpasswd
# exit the debian environment
exit
Now it's time to execute the command to start our SSH server.
debian /usr/sbin/sshd -D -e
The above command will occupy the current terminal (hang). To avoid this, you can also use the built-in scheduled tasks to make the SSH service start automatically with the FIRERPA service. Next, execute crontab -e and add the following rule, then restart the FIRERPA service or device. For documentation on scheduled tasks, you can also refer to the Scheduled Tasks section.
@reboot debian /usr/sbin/sshd -D -e >~/sshd.log 2>&1
Now, obtain the device's IP address, then execute the following command on your computer and enter the password lamda to log in.
ssh root@192.168.x.x
You can unleash your creativity and explore endless possibilities. It is a small Linux server.