Here's my Packer file.
{
"variables": {
"account_json": "{{env `packer_account_json`}}"
},
"builders": [
{
"type": "googlecompute",
"account_file": "{{user `account_json`}}",
"project_id": "united-course-124523",
"source_image": "debian-8-jessie-v20160711",
"zone": "us-central1-a",
"instance_name": "hub-{{timestamp}}",
"image_name": "hub-{{uuid}}",
"image_description": "Elasticsearch 2.3.4."
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 20",
"echo \"slept for 20 seconds.\""
]
},
{
"type": "file",
"source": "../scripts/install-elastic.sh",
"destination": "../scripts/install-elastic.sh"
},
{
"type": "shell",
"script": "../scripts/install-elastic.sh",
"pause_before": "3s"
}
]
}
I run this and then get an SSH error as shown (with executing command)
$ packer build elastic-2.3.4.json
googlecompute output will be in this color.
==> googlecompute: Checking image does not exist...
==> googlecompute: Creating temporary SSH key for instance...
==> googlecompute: Creating instance...
googlecompute: Loading zone: us-central1-a
googlecompute: Loading image: debian-8-jessie-v20160711 in project united-course-124523
googlecompute: Loading machine type: n1-standard-1
googlecompute: Loading network: default
googlecompute: Requesting instance creation...
googlecompute: Waiting for creation operation to complete...
googlecompute: Instance has been created!
==> googlecompute: Waiting for the instance to become running...
googlecompute: IP: 104.197.225.237
==> googlecompute: Waiting for SSH to become available...
==> googlecompute: Error waiting for SSH: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
==> googlecompute: Deleting instance...
googlecompute: Instance has been deleted!
==> googlecompute: Deleting disk...
googlecompute: Disk has been deleted!
Build 'googlecompute' errored: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
I've been looking at the Packer docs here https://www.packer.io/docs/provisioners/file.html regarding the file upload, and don't see anything about making an SSH connection, and also have been checking out the docs on remote ssh here https://www.packer.io/docs/provisioners/shell.html but still don't see what the issue is exactly that is causing the image to error out with the sh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
message.
I also added the communicator key and value to ssh per @tekjava suggested and still the same error. My builder looked like this after the addition.
{
"type": "googlecompute",
"account_file": "{{user `account_json`}}",
"project_id": "united-course-124523",
"source_image": "debian-8-jessie-v20160711",
"zone": "us-central1-a",
"instance_name": "{{user `instance_name`}}",
"image_name": "elastic-{{uuid}}",
"image_description": "Elasticsearch 2.3.4.",
"communicator": "ssh"
}