Skip to content

Commit fdbb5fe

Browse files
committed
Describe how the app works
1 parent e7b089e commit fdbb5fe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ docker run -e SSH_AUTH_SOCK=/tmp/.ssh-auth-sock -l com.ensody.ssh-agent-inject .
2929

3030
Note that this project is itself using ssh-agent-inject with VS Code (see `.devcontainer/`).
3131

32+
## How it works
33+
34+
This project consists of two applications that communicate through stdio: `ssh-agent-inject` and `ssh-agent-pipe` which is embedded within the `ssh-agent-inject` binary (that's why you don't see it in the release archive).
35+
36+
The `ssh-agent-inject` command runs on the host and
37+
38+
* watches Docker for containers having the `com.ensody.ssh-agent-inject` label
39+
* copies the embedded `ssh-agent-pipe` binary into those containers
40+
* runs `ssh-agent-pipe` within each container via `docker exec`
41+
* connects to the host's ssh-agent (one connection per container)
42+
* forwards the host's ssh-agent to `ssh-agent-pipe` via stdio
43+
44+
The `ssh-agent-pipe` command runs in the container and
45+
46+
* listens on a UNIX socket at `$SSH_AUTH_SOCK`
47+
* handles parallel connections on that UNIX socket
48+
* serializes all socket<->stdio communication (handles one request-response pair at a time)
49+
50+
The apps communicate via stdio because this keeps the attack surface small and makes it easier to ensure that nobody else can connect to your ssh-agent (assuming you can trust the Docker container, of course).
51+
3252
## Building
3353

3454
All required dependencies are contained in a Docker image defined in `.devcontainer/`, which can be automatically used with Visual Studio Code (or manually via Docker build & run).

0 commit comments

Comments
 (0)