<p>I'm attempting to deploy k8s "the hard way" using a terraform deployment. Please find the repo here: <a href="https://github.com/aidanSoles/kubernetes-the-hard-way-terraform" rel="nofollow noreferrer">https://github.com/aidanSoles/kubernetes-the-hard-way-terraform</a></p>

<p>It was written using Terraform 0.11 so I elected not to upgrade the code to 0.12.</p>

<p>The deployment creates Google Cloud Platform virtual machines and attempts to run scripts on them.</p>

<p>The error message I get when applying the configuration is:</p>

<pre><code>Error: Error applying plan:

2 errors occurred:
        * google_compute_instance.k8s_worker: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
        * google_compute_instance.k8s_controller: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
</code></pre>

<p>Here's a snippet of the <code>google_compute_instance</code> provisionner:</p>

<pre><code>resource "google_compute_instance" "k8s_controller" {
  boot_disk {
    auto_delete = true

    initialize_params {
      image = "${var.controller_image}"
      size  = "${var.controller_size}"
    }
  }

  can_ip_forward = true
  count          = "${var.controller_count}"
  machine_type   = "${var.controller_type}"
  name           = "k8s-controller${count.index}"

  network_interface {
    access_config = {}
    subnetwork    = "${google_compute_subnetwork.k8s_subnet.name}"
  }

  metadata {
    creator = "${var.user}"
  }

  provisioner "file" {
    connection {
      private_key = "${file(var.ssh_path)}"
      user        = "${var.user}"
      type        = "ssh"
    }

    destination = "add-ssh-keys.sh"
    source      = "${var.scripts_path}/add-ssh-keys.sh"
  }
}
</code></pre>

<p>You could find the full script here: <a href="https://github.com/aidanSoles/kubernetes-the-hard-way-terraform/blob/master/compute.tf" rel="nofollow noreferrer">https://github.com/aidanSoles/kubernetes-the-hard-way-terraform/blob/master/compute.tf</a></p>

<p>I ensured that the <code>user</code> and <code>ssh_path</code> variable values are correct by doing <code>ssh -i</code>.
I  also tried adding the <code>agent = false</code> parameter to the file provisionner with no avail.</p>

<p>Any idea what could be the root of the issue? Many thanks.</p>

Ash
<p><strong>Regarding the documentation:</strong></p>

<p>I have followed that guide and confirm that it's working. </p>

<p>I have attempted that with <a href="https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip" rel="nofollow noreferrer">terraform-0.11.14</a> . It appeared that the config files aren't compatible with terraform 0.12 at the moment.</p>

<p><strong>Regarding the error:</strong></p>

<pre><code>ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
</code></pre>

<p>Please check the following:</p>

<ul>
<li><p>if your <code>&lt;username&gt;@&lt;hostname&gt;</code> combination matches the ones you have in your public key provided on step "5. Create a service account". You can get these with <code>hostname</code> and <code>whoami</code> commands.</p>

<pre><code>$ whoami &amp;&amp; hostname
superman
my_pc

$ cat ~/.ssh/tform_rsa.pub | awk '{print $3}'
superman@my_pc
</code></pre>

<p>I succeed  reproducing exact same symptoms only when made typo in a public key I pasted under Metadata/SSH Keys on GCP. That is why either there is a typo or mismatch between private key you specified in <code>variables.tf</code> and public key uploaded to GCP. </p></li>
<li><p>permissions on your private key (the one you are using for ssh ). 
It shall be set to 600 (-rw-------) as well as permissions on key files in <code>certs</code> directory.</p></li>
</ul>

<p>Hope that helps :-)</p>
