• Stars
    star
    110
  • Rank 310,384 (Top 7 %)
  • Language
    Shell
  • Created almost 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ssh-agent

ssh-agent in a container.

Usage

Run a long-lived container named ssh-agent.

This container declares a volume that hosts the agent's socket so that other invocations of the ssh client can interact with it. Specify a UID if you would like non-root ssh clients in other containers to be able to connect.

docker run -u 1001 -d -v ssh:/ssh --name=ssh-agent whilp/ssh-agent:latest

Add your ssh keys

Run a temporary container which has access to both the volumes from the long-lived ssh-agent container as well as a volume mounted from your host that includes your SSH keys. This container will only be used to load the keys into the long-lived ssh-agent container. Run the following command once for each key you wish to make available through the ssh-agent:

docker run -u 1001 --rm -v ssh:/ssh -v $HOME:$HOME -it whilp/ssh-agent:latest ssh-add $HOME/.ssh/id_rsa

Access via other containers

Now, other containers can access the keys via the ssh-agent by setting the SSH_AUTH_SOCK environment variable. For convenience, containers that have access to the volume containing SSH_AUTH_SOCK can configure their environment using runit's chpst tool:

docker run --rm -v ssh:/ssh -it alpine:edge /bin/sh -c "apk --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing add runit && chpst -e /ssh/env /usr/bin/env | grep SSH_AUTH_SOCK"
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
(1/1) Installing runit (2.1.2-r3)
  0% [                                           ]78  1% [                                           ]78 10% [####                                       ]78 17% [#######                                    ]78 24% [##########                                 ]78 36% [###############                            ]78 51% [######################                     ]78 62% [##########################                 ]78 72% [###############################            ]78 82% [###################################        ]78100% [###########################################]78Executing busybox-1.24.2-r2.trigger
OK: 5 MiB in 12 packages
SSH_AUTH_SOCK=/ssh/auth/sock

Examples

List Keys

docker run --rm -it -v ssh:/ssh -e SSH_AUTH_SOCK=/ssh/auth/sock ubuntu /bin/bash -c "apt-get update && apt-get install -y openssh-client && ssh-add -l"

Notes

  • this container provides ssh-agent support; other common ssh functionality (including known_hosts management) is out of scope

Compatibility

This approach is tested with:

  • OSX / Virtualbox / docker-machine
  • OSX / docker for mac

More Repositories

1

cli

Python framework for command line applications
Python
54
star
2

git-urls

git-urls parses git URLs
Go
33
star
3

envcrypt

Like gpg and chpst got married
Go
22
star
4

unbound-ec2

Answer simple DNS queries using EC2 API calls
Python
17
star
5

python-script

An ideal Python script might look like this.
Python
16
star
6

world

๐Ÿก Extreme dotfiles, all reproducible everything, a model home.
Starlark
9
star
7

dotfiles

Python
8
star
8

puppet-openbsd

Extensions to and replacements for the default openbsd providers in Puppet.
Ruby
8
star
9

git-get

Go
6
star
10

tsar

Time series archive and retrieval.
Python
5
star
11

sideshow

A pedantic (X)HTML5/CSS/Jquery presentation tool.
JavaScript
5
star
12

technotron

A system for discovering and streaming techno music.
Python
5
star
13

envelop

Run commands with environment variables populated from 1password
Go
4
star
14

clusterui

Run interactive/UI jobs in a Condor cluster.
Python
3
star
15

ptemplate

Lightweight, data-driven templating in Python.
C++
3
star
16

pdalerts

Visualize your Pagerduty alerts
Python
3
star
17

neat

Tiny WSGI framework.
Python
3
star
18

statzlogger

A sawzall-like statistics gathering extension to Python's stdlib logging.
Python
3
star
19

prociolog

A Popen wrapper that makes logging process IO easy.
Python
2
star
20

mgmt

Home of ##mgmt on freenode
2
star
21

latin

Latin (Computer) Modern fonts and styles
2
star
22

stacklogger

Stack-aware logger for Python.
Python
2
star
23

dotfiles-old

My command line configs (passwords changed to protect the innocent).
Vim Script
2
star
24

redispatcher

Asynchronous Redis client for Python
Python
2
star
25

ycomments

news.yc comments on ur pages.
JavaScript
1
star
26

indico

Fork/mirror of http://indico-software.org/wiki/Download#Gitsources
1
star
27

chessjs

Play chess in your browser.
1
star
28

cloudplay

play the cloud
Python
1
star
29

tempt

Run in a temporary directory and then cleanup
Go
1
star
30

hep-hdfs

HDFS configuration for hep.wisc.edu
Shell
1
star
31

wff

Wisconsin Film Fest selections.
Python
1
star
32

puppet-lfod.us

Puppet configuration for lfod.us.
1
star
33

scriptloader

scriptloader loads scripts (into nose)
Python
1
star
34

talks

JavaScript
1
star
35

old-pages

1
star
36

gsido

Run commands using glexec.
Python
1
star
37

dtseiler-dotfiles

I already have a dotfiles...
1
star
38

wcm.aier.us

Content and build scripts for http://wcm.aier.us/
CSS
1
star
39

cloudscraper

Stream music from the cloud with your CLI
Python
1
star
40

temp-history

Fetch max and average temperature for past dates.
Python
1
star
41

vault

Shell
1
star
42

oplop

A slightly tweaked version of http://oplop.appspot.com/
JavaScript
1
star
43

hepfab

Fabric stuff for hep.wisc.edu
Python
1
star
44

c9

1
star
45

tracksandplaylists

Build XSPF playlists for streaming services.
Python
1
star
46

xone

Python
1
star
47

acmoi

My acme tools
Go
1
star
48

taskmaster

taskmaster masters tasks.
Python
1
star
49

linux-lhc

Slides for a talk on how the University of Wisconsin uses Linux and free software to solve big physics problems
1
star
50

viking

Vi keybindings for Firefox
Shell
1
star