coolfarmer
coolfarmer

Reputation: 554

Foward my ssh key from my Windows10 to my docker container

After reading this thread, I am not able to 100% foward my key, I'm blocked at step where I should run "ssh-add".

Here is a part of my docker-compose.yml:

engine:
    build: ./docker/engine/
    volumes:
        - "./:/var/www/docker:rw"
        - "./docker/engine/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
        - $SSH_AUTH_SOCK:/tmp/agent.sock
    environment:
        - SSH_AUTH_SOCK=/tmp/agent.sock

On my container, I can see without problem the file "/tmp/agent.sock" and the ENV var "SSH_AUTH_SOCK" when I print them with printenv.

After that I start ssh-agent with:

`eval `ssh-agent -s`

Then I add the ssh-key:

ssh-add

But if I print the last error (echo $?), I get 1.

From doc: Exit status is 0 on success, 1 if the specified command fails, and 2 if ssh-add is unable to contact the authentication agent.

I tried so much thing, I have no other ideas, I have visited all the possible links on google (damn).

If you have a solution (or path to one), you will be my hero!

Thanks.

Upvotes: 5

Views: 2428

Answers (1)

JnMik
JnMik

Reputation: 19

Same here,

No issue on linux while sharing ~/.ssh via volume, on windows tho it's another story. I managed to have my keys in the /.ssh folder in the container, but docker consider they are too opened (chmod > 600) so it's impossible to composer install or stuff like that. I don't know if this could be related to the way linux read NTFS Permission or something like that.

Either way, it's not working and I tried a lots of permission change

Edit: I've post this in Github, we might get some help from there : https://github.com/docker/docker/issues/27685

Upvotes: 1

Related Questions