SSH in the Middle AI Docker Securer
SSH to github (or other ssh-based foundry, theoretically) handled by a proxy that keeps user's keys secret in the proxy server.
The intention is that you can simply check out this repo and use it as-is after
populating a .env file and the volumes. You can copy from .env.example for
your .env file.
Example docker compose environment:
environment:
- SSHITMAIDS_DEST=${SSHITMAIDS_DEST:-"git@github.com:22"}
- GENERATE_CLIENT_CONFIG=${SSHITMAIDS_GENERATE_CLIENT_CONFIG:-"false"}
- CLIENT_DEST=${SSHITMAIDS_CLIENT_DEST:-"git@sshitmaids:22"}- Destination user, server, and port is configured with the .env var
SSHITMAIDS_DEST. eg.:git@github.com:22. - Public port is configured with the .env var
SSHITMAIDS_PUBLIC_PORT - Use
SSHITMAIDS_GENERATE_CLIENT_CONFIG=true, which generates config files in thessh-clientvolume using the value fromCLIENT_DEST, so this can be included in the clients' ssh config. If noCLIENT_DESTis provided, it assumes sshitmaids is reachable atgit@sshitmaids:22 - Use
SSHITMAIDS_DO_KEYSCAN=trueto do ssh server keyscan to writeknown_hostsin thesshitmaidsvolume, but github's ssh server keyscan is rate-limited so requesting it regularly is pointless.
There are two read/write volumes needed by sshitmaids, with example docker compose bindings below:
volumes:
- ./volumes/sshitmaids:/root/sshitmaids
- ./volumes/ssh-client:/root/ssh-client- SSH keys go in these volumes.
sshitmaidsvolume: SSH Keys for the account that you wish to use to connect to the target foundry (eg github).ssh-clientvolume: Public SSH keys for your client that sshitmaids will add to./volumes/ssh/sshitmaids/authorized_keys, ensuring that only the authorized client can access the mitm server.
- All SSH keys are assumed to be
id_ed25519andid_ed25519.pub.
- The volumes are not used live. Data in the volumes are written into the
.sshdirs on the server on startup. If changes are made to the volumes, the changes can be re-loaded into.sshdirs by calling:
docker exec sshitmaids /reconfigure.
Because the client doesn't know that it's being forwarded and the server doesn't
know the original intended destination of the client, .ssh/config files are
used to arrange the routing. An optional file can be generated for the client to
use, described above, or the client can be instructed to connect directly to the
sshitmaids server (git@sshitmaids:22 inside the same docker net,
git@localhost:SSHITMAIDS_PUBLIC_PORT on the host).
I kept making the typo while working on it when it was called "ssh-mitm" and decided to roll with it.
- Support more simultaneous targets
- Testing with gitlab
- Automated testing
- Read-only volumes
- Get
reconfigureinto path properly
MIT. See LICENSE