HUB
Sign inSign up

sbx/github-ssh:latest

Multi-platform
Manifest digest

sha256:134559cb65efb99c34544be05a9290abc3a800889be0c624f1806d4641c9458b

Last pushed

1 day by dhibot

Type

Sandbox Kit

Manifest digest

sha256:134559cb65efb99c34544be05a9290abc3a800889be0c624f1806d4641c9458b

yaml
schemaVersion: "3"
displayName: GitHub SSH
author: Docker, Inc. https://docker.com
description: Pre-populates GitHub host keys so SSH operations work without interactive host verification prompts.
sourceUrl: https://github.com/docker-hardened-images/definitions
version: 1.1.1
licenses:
    - Apache-2.0
kind: mixin
provides:
    - github-ssh
requires:
    - deb/jq
    - deb/openssh-client
capabilities:
    - type: com.docker.sandbox/ssh-agent@1
      config:
        authenticate:
            - [email protected]
        phase: runtime
        unrestricted: false
    - type: com.docker.sandbox/network-policy@1
      config:
        install:
            allow:
                - api.github.com
        runtime:
            allow:
                - github.com
    - type: com.docker.sandbox/lifecycle@1
      config:
        install:
            - command:
                - bash
                - -c
                - |
                  set -euo pipefail
                  mkdir -p /home/agent/.ssh
                  chmod 700 /home/agent/.ssh
                  chown agent:agent /home/agent/.ssh
                  keys=$(mktemp /home/agent/.ssh/github-keys.XXXXXX)
                  trap 'rm -f "$keys"' EXIT
                  curl -fsSL https://api.github.com/meta \
                    | jq -er '.ssh_keys | if type == "array" and length > 0 and all(.[]; type == "string" and length > 0) then .[] | "github.com " + . else error("missing SSH host keys") end' \
                    > "$keys"
                  touch /home/agent/.ssh/known_hosts
                  # Append only missing keys; user entries survive create retries.
                  while IFS= read -r key; do
                    if ! grep -Fqx -- "$key" /home/agent/.ssh/known_hosts; then
                      printf '%s\n' "$key" >> /home/agent/.ssh/known_hosts
                    fi
                  done < "$keys"
                  chmod 644 /home/agent/.ssh/known_hosts
                  chown agent:agent /home/agent/.ssh/known_hosts
              description: Fetch and install GitHub host keys from api.github.com/meta
              env:
                - HTTP_PROXY
                - HTTPS_PROXY
                - NO_PROXY
                - http_proxy
                - https_proxy
                - no_proxy
              user: "0"
    - type: com.docker.sandbox/agent-context@1
      optional: true
      config:
        content: |
            ## GitHub SSH authentication

            GitHub's host keys are pre-populated in `~/.ssh/known_hosts`, so SSH
            operations to GitHub (clone, push, pull) work without interactive host
            verification prompts.
    - type: com.docker.sandbox/agent-context@2
      optional: true
      config:
        content: |
            ## GitHub SSH authentication

            GitHub's host keys are pre-populated in `~/.ssh/known_hosts`, so SSH
            operations to GitHub (clone, push, pull) work without interactive host
            verification prompts.
args:
    version:
        required: true
        description: Kit revision supplied by the DHI build
        buildArg: VERSION