1.简介
eadb(eBPF Android Debug Bridge)提供了一个强大的 Linux shell 环境,可以在 Android 设备上运行 BCC / bpftrace / bpftool。
2.安装eadb
从源码构建,需要rust工具链
1
2
3
| git clone https://github.com/tiann/eadb
cargo build
cargo install eadb
|
3.构建环境
可以自行构建环境也可以使用已有存档,构建环境时仅支持 Ubuntu / Debian 构建在Android上运行得系统镜像,
1
2
3
4
| # 安装qemu-user-static 和 debootstrap
sudo apt update && sudo apt install qemu-user-static debootstrap
# 构建eadb(需要root)
sudo eadb build # 构建完成后,会在工作目录得到一个debianfs-***.tar.gz映像
|
4.使用
eadb支持adb和ssh两种方式连接设备,他们都需要root权限。可通过 adb_root和MagiskSSH来启用adb root和ssh功能。
1
2
3
4
| # 在Android设备构建linux shell 环境
eadb --ssh root@ip prepare -a deb.tar.gz
# 连接到Android设备
eadb --ssh root@ip shell # 连接成功后,会在工作目录得到一个adb shell
|
通过这个命令会进入 eadb 环境,得到一个 shell,可以使用 apt update 更新源码和安装软件(比如 clang、llvm、bpftrace),甚至可以安装 Rust / Golang 或者 gcc 在这个设备上做开发!
5.配置SSH
在linux shell环境中配置ssh,方便远程开发。需要准备一份ssh公钥和私钥。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| # 安装ssh
apt-get update && apt-get install openssh-server
# 配置ssh
vim /etc/ssh/sshd_config
# 修改如下配置:
Port 2233 # 修改端口, 防止与MagiskSSH端口冲突
PermitRootLogin yes # 允许root登录
PubkeyAuthentication yes # 允许公钥认证
# 钥复制 /root/.ssh/authorized_keys 中
echo "公钥内容" >> /root/.ssh/authorized_keys
# 修改权限
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
# 重启ssh服务
service ssh restart
# 测试
ssh root@ip -p 2233
|