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

"Your ssh key was not loaded correctly, try one more time." #5

Closed stevepereira closed 9 years ago

stevepereira commented 9 years ago

OSX: When I run hodor, I get a new agent PID every time, and "Your ssh key was not loaded correctly, try one more time." - it seems like the agent PID isn't parsing correctly and starting a fresh agent.

When I run the command manually: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker docker@192.168.59.103 'rm -f /tmp/docker_socket && eval ssh-agent -a /tmp/docker_socket && ssh-add' I get the exit code 1 as expected

It seems like there's no check for a running ssh-agent, is that something we need to account for or am I totally off base?

stevepereira commented 9 years ago

PS: saw issue 2, but I'm running a totally fresh checkout

I am running the vbguest iso for boot2docker (1.2.0) but when I run the eval ssh-agent -s as you describe I get a new PID even though ssh-agent is already running (and then a bunch of running ssh-agents)

I also tried a totally stock boot2docker iso as well, same result

rogeriopradoj commented 9 years ago

Same issue here.

Running boot2docker https://bfirsh.s3.amazonaws.com/boot2docker/boot2docker-1.3.0-fd99db6.iso

gansbrest commented 9 years ago

I will need to see some output:

@stevepereira This command ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker docker@192.168.59.103 'rm -f /tmp/docker_socket && evalssh-agent -a /tmp/docker_socket&& ssh-add should return 0 if there are no errors.

It's ok that it opens a new session every time, it should create socket under /tmp/docker_socket on the VM.

To debug the issue, stop and destroy the boot2docker, then init it again ( don't run hodor ).

Then run this command find ~/.ssh -maxdepth 1 -type f -not \\( -name *authorized_keys* -o -name *config* \\) -exec scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker {} docker@#{@docker_host_ip}:~/.ssh \\\; 2>&1

(replace docker_host_ip with your VM ip).

This command will copy your ssh keys to VM. To make sure it worked, boot2docker ssh to the VM and ls -la ~/.ssh folder, it should have your keys.

Then, while you are on VM, run rm -f /tmp/docker_socket && evalssh-agent -a /tmp/docker_socket&& ssh-add and see if you get any errors on this setp.

Paste output for each step please.

gansbrest commented 9 years ago

I think the issue you guys were experiencing was simple in nature. You probably didn't have id_rsa key in your ~/.ssh folder ( at the moment I didn't create an option to choose different private key ). Maybe you never generated ssh key pair. It's optional and I added extra check for that. Thanks for report.

Reopen if issue still persist for you.

carterbancroft commented 9 years ago

I'm still experiencing this issue with the latest version and making an attempt to debug based on your recommendations. I think there is a syntax error in this find ~/.ssh -maxdepth 1 -type f -not \\( -name *authorized_keys* -o -name *config* \\) -exec scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker {} docker@#{@docker_host_ip}:~/.ssh \\\; 2>&1

After replacing the docker_host_ip and running the command it errors with -bash: syntax error near unexpected token('`. I'm trying to learn enough about that command to figure out where the error lies, but maybe you can spot it.

FWIW, I do have an id_rsa key in my ~/.ssh folder.

Also, I don't have privileges to re-open this issue.

stevepereira commented 9 years ago

Hey thanks for following up! I've been traveling and haven't been able to do the testing, but I also had to update to osx 10.10 - I'll check against that but maybe not until Nov when I get some laptop time

On Sat, 25 Oct 2014 19:35 Carter Bancroft notifications@github.com wrote:

I'm still experiencing this issue with the latest version and making an attempt to debug based on your recommendations. I think there is a syntax error in this find ~/.ssh -maxdepth 1 -type f -not ( -name _authorizedkeys -o -name config ) -exec scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker {} docker@#{@docker_host_ip}:~/.ssh \; 2>&1

After replacing the docker_host_ip and running the command it errors with -bash: syntax error near unexpected token('`. I'm trying to learn enough about that command to figure out where the error lies, but maybe you can spot it.

— Reply to this email directly or view it on GitHub https://github.com/gansbrest/hodor/issues/5#issuecomment-60490358.

gansbrest commented 9 years ago

@alt234 Could you provide output of ls -la ~/.ssh of your Mac workstation?

Then paste return status of this command ( run from your Mac host and replace with your docker VM ip ) - ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker docker@192.168.59.103 'rm -f /tmp/docker_socket && evalssh-agent -a /tmp/docker_socket&& ssh-add'

To get return status just execute $? after you run that command.

carterbancroft commented 9 years ago

Sure thing!

$ ls -la ~/.ssh
total 104
drwxr-xr-x  13 Carter  staff   442 Oct 17 15:10 .
drwxr-xr-x+ 68 Carter  staff  2312 Oct 24 15:33 ..
-rwxr-xr-x   1 Carter  staff   168 Feb 15  2014 config
-rw-------   1 Carter  staff  1766 Feb 15  2014 heroku
-rw-r--r--   1 Carter  staff   410 Feb 15  2014 heroku.pub
-rw-------   1 Carter  staff  1679 Oct 17 15:10 id_boot2docker
-rw-r--r--   1 Carter  staff   414 Oct 17 15:10 id_boot2docker.pub
-rw-------   1 Carter  staff  1675 Jan 26  2014 id_rsa
-rwxr-xr-x   1 Carter  staff   402 Jan 26  2014 id_rsa.pub
-rwxr-xr-x   1 Carter  staff  9267 Oct  3 10:21 known_hosts
-rw-------   1 Carter  staff  1766 Jan 26  2014 linode
-rwxr-xr-x   1 Carter  staff   425 Jan 26  2014 linode.pub
-rw-------   1 Carter  staff   669 Oct  3 10:20 test.pem

and...

$ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_boot2docker docker@192.168.59.103 'rm -f /tmp/docker_socket && eval `ssh-agent -a /tmp/docker_socket` && ssh-add'
Warning: Permanently added '192.168.59.103' (RSA) to the list of known hosts.
Agent pid 1391

finally...

$ echo $?
1
gansbrest commented 9 years ago

Seems like this was fixed by https://github.com/gansbrest/hodor/commit/992e5d053305efa6838e94bb3c7427e92cc74f91