gansbrest / hodor

Small utility to streamline dev process with Docker on OS X (Boot2Docker/Docker Machine) and Linux
MIT License
154 stars 11 forks source link

Could not open a connection to your authentication agent. #2

Closed gzoritchak closed 10 years ago

gzoritchak commented 10 years ago

Hi,

Nice project that can be very precious for simplifying development with docker.

I'm trying to make it working on my Mac. I have this message:

/usr/local/bin/hodor:20: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts.
Could not open a connection to your authentication agent.
Your ssh key was not loaded correctly, try one more time. 

Since I'm not understanding the complex commands you are launching :-), I'm asking some help on how to solve the problem.

gansbrest commented 10 years ago

Hey Gaetan,

Sorry, the tool is a little raw at the moment :) You seem to have 2 problems:

Also I found this post which describes how to run ssh-agent on boot, which is how most people should have it if they use ssh http://billdieter.wordpress.com/2011/09/30/automatically-start-ssh-agent-on-mac-os-x/

Let me know if it worked for you.

gzoritchak commented 10 years ago

No, it's not working:

$ ssh-add
Could not open a connection to your authentication agent.

$ eval `ssh-agent -s`
Agent pid 6484

$ ssh-add
Identity added: /Users/gaetanzoritchak/.ssh/id_rsa (/Users/gaetanzoritchak/.ssh/id_rsa)

$ hodor grunt build
/usr/local/bin/hodor:20: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts.
Could not open a connection to your authentication agent.
Your ssh key was not loaded correctly, try one more time.
gansbrest commented 10 years ago

Hm, interesting.. You know what, what version of Boot2docker are u using? Default boot2docker.iso as well? Try to ssh to the Docker VM ( boot2docker ssh ) and then run ssh-add there. If you get same "Could not open a connection to your authentication agent." error, that means something is messed up with ssh-agent inside VM.

Then, if that's the problem, you can try evalssh-agent -s`` inside of the VM and then run hodor from your host.

I tried latest boot2docker VM and it was fine there, but who knows. We will get to the bottom of it! )

By the way, you can comment out lines 78-81 and see how far you get afterwards. But I would rather us find the problem :)

gzoritchak commented 10 years ago

I upgraded to last version 1.2.0 => same result.

ssh-add from the vm => Could not open a connection to your authentication agent. eval ssh-agent -s => Agent pid 872

hodor grunt run
/usr/local/bin/hodor:20: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts.
SSH_AUTH_SOCK=/tmp/docker_socket; export SSH_AUTH_SOCK;
SSH_AGENT_PID=969; export SSH_AGENT_PID;
echo Agent pid 969;
Could not open a connection to your authentication agent.
Your ssh key was not loaded correctly, try one more time.
gansbrest commented 10 years ago

So, seems like something is up with your boot2docker.iso. When you upgraded boot2docker, did you remove old boot2docker.iso? If not, find and remove it ( it should be in your home dir somewhere ), then do boot2docker init, it will download new version.

Don't forget to run boot2docker destroy before you remove .iso to clean things up.

Then try to run hodor, if same error happens. Ssh to boot2docker and run following commands - ssh-agent -a /tmp/docker_socket && SSH_AUTH_SOCK=/tmp/docker_socket && ssh-add

also check .ssh folder of the current user (docker) inside of boot2docker VM, it should have your keys copied from workstation.

Report back if you can please. And thanks a lot for your time by the way!

gzoritchak commented 10 years ago

Quick report :

boot2docker poweroff boot2docker destroy rm boot2docker.iso boot2docker init => 2014/09/29 18:39:26 Downloading boot2docker ISO image...2014/09/29 18:39:27 Latest release is v1.2.0

boot2docker up 2014/09/29 18:42:18 Waiting for VM to be started... ........... 2014/09/29 18:42:50 Started. 2014/09/29 18:42:50 Your DOCKER_HOST env variable is already set correctly.

hodor => same error.

boot2docker ssh docker@boot2docker:~$ ssh-agent -a /tmp/docker_socket && SSH_AUTH_SOCK=/tmp/docker_socket && ssh-add bind: Address already in use

ll .ssh => all my keys are here

Thanks for YOUR time,

gansbrest commented 10 years ago

What if you stop your boot2docker, start it again.

Then ssh to it. Try ssh-add. It will show the "usual error" probably, then try evalssh-agent -s`, note thatevalis very important here. By itselfssh-agent -sjust gives variables you need to set in your terminal ( basically copy/paste into terminal ),eval` does it for you.

After that try ssh-add again, it should not show the error message. Paste back commands with output as you go please.

gzoritchak commented 10 years ago

$ boot2docker down

$ boot2docker up 2014/09/29 20:31:49 Waiting for VM to be started... ....... 2014/09/29 20:32:10 Started. 2014/09/29 20:32:10 Your DOCKER_HOST env variable is already set correctly.

$ boot2docker ssh

.

              ## ## ##       ==
           ## ## ## ##      ===
       /""""""""""""""""_**/ ===
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
       ____** o          **/
         \    \        **/
          \****______/

| | __ | |_| \ **| | | | _ _ | ' \ / \ / | | ) / ` |/ \ / | |/ / \ '**| | |) | () | () | | / **/ (| | () | (| < / | |./ _/ **/ |____,|/ _||____|| boot2docker: 1.2.0 3.16.1-config-file : e75396e - Fri Aug 22 06:45:30 UTC 2014 docker@boot2docker:~$ ssh-add Could not open a connection to your authentication agent. docker@boot2docker:~$ eval ssh-agent -s Agent pid 798 docker@boot2docker:~$ ssh-add docker@boot2docker:~$ exit 2014/09/29 20:34:00 exit status 1

$ hodor /usr/local/bin/hodor:20: warning: Insecure world writable dir /usr/local in PATH, mode 040777 Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts. SSH_AUTH_SOCK=/tmp/docker_socket; export SSH_AUTH_SOCK; SSH_AGENT_PID=895; export SSH_AGENT_PID; echo Agent pid 895; Could not open a connection to your authentication agent. Your ssh key was not loaded correctly, try one more time.

$ hodor /usr/local/bin/hodor:20: warning: Insecure world writable dir /usr/local in PATH, mode 040777 Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts. Could not open a connection to your authentication agent. Your ssh key was not loaded correctly, try one more time.

gansbrest commented 10 years ago

Ok, now we are getting somewhere. I don't have mac with me at the moment, but if you could try to stop your boot2docker, then replace line 78 of the hodor with this one:

system("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker docker@#{@docker_host_ip} '[ -e /tmp/docker_socket ] || evalssh-agent -a /tmp/docker_socket&& ssh-add'")

Then run hodor, see if something changed ( don't forget to start boot2docker )

gzoritchak commented 10 years ago

A little change ;-):

$ hodor /usr/local/bin/hodor:20: warning: Insecure world writable dir /usr/local in PATH, mode 040777 Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts. Agent pid 963 Identity added: /home/docker/.ssh/id_rsa (/home/docker/.ssh/id_rsa)

Either your task or cmd property not found in the config

$ hodor grunt run /usr/local/bin/hodor:20: warning: Insecure world writable dir /usr/local in PATH, mode 040777 Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts. Could not open a connection to your authentication agent. Your ssh key was not loaded correctly, try one more time.

gansbrest commented 10 years ago

@gzoritchak try it now please, my last commit should fix your issue. It seemed to be related to the fact that I had ~/.ssh/config file with the following contents on my laptop:

Host *
ForwardAgent yes

That enabled ssh forwarding cause ssh-add to work inside of the container.. Anyways, it's not required now, hopefully :)