sha256:5241ceb0115364330eee7e0636840edc064e1e6132e3859a298116e499215d0d
Last pushed
27 days by cdupuis
Type
Sandbox Kit
Manifest digest
sha256:5241ceb0115364330eee7e0636840edc064e1e6132e3859a298116e499215d0d
schemaVersion: "3"
displayName: GitHub via forwarded YubiKey (PIV)
description: |
Prepares a sandbox for GitHub git over the forwarded host ssh-agent
(YubiKey PIV slot 9a, served by docker-piv-agent). The private key and
PIN never enter the sandbox — each git network op makes the HOST YubiKey
blink for a tap, which the human approves. Pairs with host-side
ssh-agent forwarding (the daemon's SSH_AUTH_SOCK at startup).
What it does:
- network-policy runtime: allow GitHub SSH egress. sbx egress is a
TLS-intercepting HTTP(S) proxy, so raw SSH on port 22 is closed at kex
by default; this opens it (also covers ssh.github.com:443 for the 443
fallback).
- lifecycle startup (idempotent; runs on every boot): accept
GitHub's host key on first use (a non-TTY agent can't answer the
interactive yes/no prompt), and rewrite any HTTPS github URL to SSH so
all git traffic routes through the forwarded agent.
sourceUrl: https://github.com/docker/docker-piv-agent
version: 1.0.0
kind: mixin
capabilities:
- type: com.docker.sandbox/network-policy@1
config:
runtime:
allow:
- github.com:22
- ssh.github.com:443
- type: com.docker.sandbox/lifecycle@1
config:
startup:
- command:
- sh
- -c
- mkdir -p ~/.ssh && chmod 700 ~/.ssh && (grep -q "StrictHostKeyChecking accept-new" ~/.ssh/config 2>/dev/null || printf "Host github.com\n StrictHostKeyChecking accept-new\nHost ssh.github.com\n StrictHostKeyChecking accept-new\n" >> ~/.ssh/config)
description: Accept GitHub host key on first use (non-TTY agent has no prompt)
user: agent
- command:
- sh
- -c
- git config --global url."[email protected]:".insteadOf "https://github.com/"
description: Route github HTTPS -> SSH (use forwarded YubiKey agent)
user: agent
- command:
- sh
- -c
- 'if [ -S "$SSH_AUTH_SOCK" ]; then echo "github-yubikey kit: forwarded agent OK ($SSH_AUTH_SOCK)"; ssh-add -l 2>&1 | head -1; else echo "github-yubikey kit: ERROR no SSH_AUTH_SOCK — host agent not forwarded (start sbx from a shell with SSH_AUTH_SOCK set)"; exit 1; fi'
description: Diagnostic — report forwarded ssh-agent state
env:
- SSH_AUTH_SOCK
user: agent
- command:
- sh
- -c
- ssh-add -L | grep -m1 docker-piv-agent > ~/.ssh/piv_signing.pub || ssh-add -L | head -1 > ~/.ssh/piv_signing.pub
description: Write YubiKey PIV signing public key to ~/.ssh/piv_signing.pub
env:
- SSH_AUTH_SOCK
user: agent
- command:
- sh
- -c
- git config --global gpg.format ssh && git config --global user.signingkey ~/.ssh/piv_signing.pub && git config --global commit.gpgsign true && git config --global tag.gpgsign true
description: Configure git to use YubiKey PIV for signing
user: agent