Search code examples
dockeropenssldocker-machineopenssh

docker-machine create keeps asking for password


I am attempting to docker-machine create to a Ubuntu 16.04 host like this:

    ssh-keygen -R ${remote_host}
    ssh-copy-id -i ~/.ssh/id_host_rsa.pub root@${remote_host}

    docker-machine create \
        --driver generic \
        --generic-ip-address=${remote_host} \
        --generic-ssh-key ~/.ssh/id_host_rsa \
        --generic-ssh-user=root ${machine_name}

Version information:

docker --version
Docker version 19.03.6, build 369ce74a3c

docker-machine --version
docker-machine version 0.16.2, build bd45ab13

I am repeatedly asked for a password .. Why is this?

Here is the output:

...

Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: ERROR: Received disconnect from 77.68.21.66 port 22:2: Too many authentication failures
ERROR: Disconnected from 77.68.21.66 port 22

Running pre-create checks...
Creating machine...
(production) Importing SSH key...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Password: 
Detecting the provisioner...
Password: 
Provisioning with ubuntu(systemd)...
Password: 

.. etc

Solution

  • The reason for this problem was the ordering of ~/.ssh/config.

    I had a Host * entry in config first, before that of my corresponding specific server Host XX.XX.XX.XX entry.

    I moved the wildcard entry at the end of ~/.ssh/config and now the password is no longer constantly asked for and the problem is now fixed.

    I how this helps someone.