# Setup your PyGrid/PySyft Pentesting Infrastructure using docker
This is a step by step quick guide with screenshots to quickly help you set up your pentesting environment using docker on kali linux 2021
I highly advice you to setup this infrastructure on a virtual machine. In order to setup your VM, please follow the instructions on [GETTING_STARTED.md](https://github.com/bayegaspard/X-PenTest/blob/main/GETTING_STARTED.md)
Assuming you successfully installed your vm and your kali linux is working fine. Lets install docker and setup our environment.
### Requirements
- Virtual environment (Anaconda)
- Docker
### Install anaconda and set up our virtual environment
We need to start by setting up our virtual environment using conda. We first downlaod the bash script and run it then use conda to create a virtual environment. After that, we activate the virtual environment using the respective code snippet below.
```
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh
$ conda create -n <your custorm env name here e.g my_syft_env> python=3.8
$ conda activate <your custorm env name here e.g my_syft_env>
```
- After activating your virutual environment, you will see this output as seen below.

- Note : In case you want to know the different virtual environments you have in order to use the specific one related to this project, you can use the command `conda info --envs` then use `conda activate <your project virtual env directory>`
### Set up our clients addresses
- Now we need to edit the hosts files to enable multiple users to be assigned different names so they can act as our workers. To edit the host file we use the following command :
` sudo nano /etc/hosts` or `sudo vi /etc/hosts`. Feel free to use the editor of your choice.
- Copy paste this code below.
```
127.0.0.1 network
127.0.0.1 alice
127.0.0.1 bob
127.0.0.1 charlie
127.0.0.1 dan
```
- Output

### Install and setup Docker-ce
- We proceed by installing Docker-ce. You can install using your prefered method from the [docker official page](https://docs.docker.com/engine/install/ubuntu/). Others may like to try out the method below.
```
$ curl -fSsL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh
$ docker -v
```
### Install docker-compose
- Feel free to visit the official website [here](https://docs.docker.com/compose/install/) and follow guidelines. Or you can use this as well from the link provided.
```
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
```
### Clone and setup our infrastructure
- We need to clone the PyGrid repository.
```
$ git clone https://github.com/OpenMined/PyGrid.git
$ cd PyGrid
$ docker-compose up
```
- Output

- Your system is up and running and you can now use all your prefered tools in kali while keeping in mind the different ports and domains for the different workers/networks. Feel free to check on previous reconnaissance from this [link](https://github.com/OpenMined/X-PenTest/blob/main/grid/Grid-Recon.md) about the ports and reports related to the infrastructure.
- This will launch a jupyter notebook session on your default browser and you can feel free to explore and play with the different implementations in order to understand how it works.
- If it happens you don't see jupyter notebook started on your browser, you can copy paste the link which appear below from the terminal as seen below.

- You can also see the graphical outputs as seen below
- For jupyter notebook with all the different projects.

- clienst participating in the project.

### Some unexpected errors
- `Note:` In case you encounter some errors while running docker-compose up like the one below, feel free to use the solution below:

### Solution to the above error
- Run the following to solve this issue.
```
$ sudo mkdir -p /sys/fs/cgroup/system
$ sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/system
```