## Barracuda in Docker

To run a command with an opened VPN connection, just use a Docker image.

### Build the Docker image

```bash
docker build --no-cache -t barracuda .
```

### Run a command

Now you can run a command within a container. There is a wrapper script that will start the VPN connection, run your command and then stops the VPN connection again.

```bash
docker run --cap-add=NET_ADMIN -e VPN_USER=$VPN_USER -e VPN_PWD=$VPN_PWD -ti barracuda ping -c 3 twiki
```

or using `pass`

```bash
 docker run --cap-add=NET_ADMIN -e VPN_USER=$(pass seal-vpn-user) -e VPN_PWD=$(pass seal-vpn) -ti barracuda ping -c 3 roettfs1
 ```

### Connect to a machine

To connect to a computer located in the lan, type:

```bash
docker run --cap-add=NET_ADMIN -e VPN_USER=$VPN_USER -e VPN_PWD=$VPN_PWD -p 3389:3389 -ti barracuda connect <HOSTNAME>
```

Replace `<HOSTNAME>` with the ip or name of the target. You must also define the forwarding for all ports you want to use. The ports will be mapped to localhost. In the example above, a port forwarding for RDP is provided by the `-p` option.

When done, simply use `<Ctrl>+c` to stop the container.

#### Save your VPN user name

You have to install the tool `pass` to store your user name and password.

```bash
pass insert seal-vpn-user
```

Enter your user.name here.

#### Save your VPN password

```bash
pass insert seal-vpn
```

Enter your VPN password.

### Helper script to connect to a machine

You can also use the script `connect.sh` to start the VPN container. Based on the given arguments, it constructs a proper `docker run` command.

To connect to a host via RDP, run:

```shell
./connect.sh <HOSTNAME>:3389
```

By default, the given port number will be used for the local port, too. But you can also define another local port:

```shell
./connect.sh <HOSTNAME>:3389:3390
```

#### Connect to multiple hosts/ports

You can provide multiple host-port-combinations to create more than one port forwarding.

To connect to `roenb000` via RDP and to `roeserver` via SSH, run:

```shell
./connect.sh roenb000:3389 roeserver:22
```

Of course, you may specify another local port for any of these combinations.

### RDP

To forward port 3389, run:

```shell
./rdp.sh <HOSTNAME>
```
