|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +title: Docker Hosts |
| 4 | +--- |
| 5 | + |
| 6 | +# Connecting to Docker Hosts |
| 7 | + |
| 8 | +Leviathan uses SSH to connect to remote docker hosts and supports multiple ways to connect to Docker hosts. |
| 9 | + |
| 10 | +This can be configured in the `clients` section in `config.yaml` |
| 11 | +Here is an example ssh section |
| 12 | + |
| 13 | +```yaml |
| 14 | +clients: |
| 15 | + enable_local_docker: true |
| 16 | + ssh: |
| 17 | + example: # key is a nickname for this machine |
| 18 | + enable: false |
| 19 | + host: 192.168.1.69 |
| 20 | + port: 22 |
| 21 | + user: test |
| 22 | + password: "" |
| 23 | + remotepublickey: "" |
| 24 | + usepublickeyauth: false |
| 25 | +``` |
| 26 | +
|
| 27 | +## SSH user considerations |
| 28 | +
|
| 29 | +You must ensure that the ssh user that the leviathan uses can access the docker demon properly, |
| 30 | +
|
| 31 | +You can create a user with limited permissions that can only control the Docker daemon remotely. This approach follows |
| 32 | +the principle of the least privilege, providing only the specific access needed. |
| 33 | +
|
| 34 | +## Connection hierarchy |
| 35 | +
|
| 36 | +When leviathan connects to a docker host it follows the following order |
| 37 | +
|
| 38 | +1. Checks if `use_public_key_auth` is enabled then uses [public key auth](#ssh-public-key-authentication-recommended) |
| 39 | +2. If that is disabled, it checks the `passoword` section and uses [password auth](#ssh-password-authentication) |
| 40 | +3. If password is empty, then it will fallback to [host public key auth](#ssh-public-key-authentication-host-dependent) |
| 41 | + |
| 42 | +Regardless of the auth method, if the host public key is automatically stored on first |
| 43 | +connection and verified on subsequent connections. |
| 44 | + |
| 45 | +If the `remotepublickey` is set before first connect then it will be used to verify. |
| 46 | + |
| 47 | +**Leviathan requires at least 1 docker host connected at anytime, |
| 48 | +if it is unable to connect to any docker host then it will exit with a fatal error.** |
| 49 | + |
| 50 | +## Authentication Methods |
| 51 | + |
| 52 | +### SSH Public Key Authentication (Recommended) |
| 53 | + |
| 54 | +```yaml |
| 55 | +use_public_key_auth: true |
| 56 | +``` |
| 57 | + |
| 58 | +- Uses auto-generated key pair stored in Leviathan's config directory, found in `appdata/config/ssh_config` |
| 59 | +- Requires adding Leviathan's public key to remote host's `~/.ssh/authorized_keys` |
| 60 | +- No password required |
| 61 | + |
| 62 | +### SSH Password Authentication |
| 63 | + |
| 64 | +```yaml |
| 65 | +password: "some password" |
| 66 | +``` |
| 67 | + |
| 68 | +- Basic authentication method |
| 69 | +- Recommended for initial setup/testing only |
| 70 | + |
| 71 | +### SSH Public Key Authentication (Host dependent) |
| 72 | + |
| 73 | +- Uses key pair stored on the machine running leviathan typically at `~/.ssh` |
| 74 | +- Requires mounting the `.ssh` dir into the docker container or |
| 75 | +- transferring the keys manually and setting up `.ssh` inside the container file system |
| 76 | + |
| 77 | +### Local Docker Connection |
| 78 | + |
| 79 | +- Enabled by default on first run. |
| 80 | +- Requires Docker daemon running on local machine |
| 81 | +- Requires mounting `/var/run/docker.sock:/var/run/docker.sock` into the container |
| 82 | +- Disable with `enable_local_docker: false` in config.yaml |
| 83 | + |
| 84 | +# Configuration Parameters |
| 85 | + |
| 86 | +| Parameter | Required | Default | Description | Notes | |
| 87 | +|-----------------------|:--------:|:-------:|----------------------------------|----------------------------------------------------| |
| 88 | +| `enable` | No | `true` | Host availability | Set to `false` to disable host | |
| 89 | +| `host` | Yes | - | Host machine IP | `http://192.168.1.1` or `https:remote.docker.com` | |
| 90 | +| `port` | No | `22` | SSH port number | Standard SSH port used if not specified | |
| 91 | +| `user` | Yes | - | SSH login username | | |
| 92 | +| `password` | No | - | SSH password | Used for password-based authentication | |
| 93 | +| `remote_public_key` | No | - | Remote host's public key | Automatically set by Leviathan on first connection | |
| 94 | +| `use_public_key_auth` | No | `false` | Enable public key authentication | Set to `true` to use leviathan's SSH key pairs | |
| 95 | + |
| 96 | + |
0 commit comments