在macOS上将ssh-agent与docker结合使用 [英] Using ssh-agent with docker on macOS

查看:146
本文介绍了在macOS上将ssh-agent与docker结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ssh-agent将密钥转发到docker映像中并从私有github存储库中提取.

I would like to use ssh-agent to forward my keys into the docker image and pull from a private github repo.

我正在对带有boot2docker的 https://github.com/phusion/passenger-docker 进行略微修改的版本在优胜美地上.

I am using a slightly modified version of https://github.com/phusion/passenger-docker with boot2docker on Yosemite.

ssh-add -l
...key details
boot2docker up

然后,我使用在很多地方都可以看到的命令(即 https://gist.github.com/d11wtq/8699521 ):

Then I use the command which I have seen in a number of places (i.e. https://gist.github.com/d11wtq/8699521):

docker run --rm -t -i -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent my_image /bin/bash

但是它似乎不起作用:

root@299212f6fee3:/# ssh-add -l
Could not open a connection to your authentication agent.

root@299212f6fee3:/# eval `ssh-agent -s`
Agent pid 19

root@299212f6fee3:/# ssh-add -l
The agent has no identities.

root@299212f6fee3:/# ssh git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
Permission denied (publickey).

推荐答案

单线:

以下是在运行Debian Jessie映像的Ubuntu 16上进行设置的方法:

Here’s how to set it up on Ubuntu 16 running a Debian Jessie image:

docker run --rm -it --name container_name \
-v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) \
-e SSH_AUTH_SOCK=$SSH_AUTH_SOCK my_image

https://techtip.tech.blog/2016/12/04/using-ssh-agent-forwarding-with-a-docker-container/

这篇关于在macOS上将ssh-agent与docker结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆