Packer: vagrant builder ssh connection error

Created on 2 Mar 2020  ยท  8Comments  ยท  Source: hashicorp/packer

Hi all,

I'm trying to build a custom vagrant box based on "ubuntu/bionic64" box.
My configuration is here:

"provisioners": [
    {
      "type": "shell",
      "script": "install.sh"
    }
  ],
"builders": [
    {
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "ssh_port": 22,
      "source_path": "ubuntu/bionic64",
      "provider": "virtualbox",
      "add_force": true,
      "type": "vagrant"
    }
  ],

"post-processors": [
    {
      "type": "vagrant-cloud",
      "box_tag": "acik/winit",
      "access_token": "{{user `cloud_token`}}",
      "version": "{{user `version`}}"
    }
  ]

It gives the error:

==> vagrant: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain

It can't login to source box. But the documentation remarks here:

A note on SSH connections
Currently this builder only works for SSH connections, and automatically fills in all information needed for the ssh communicator using vagrant's ssh-config.

I understand that it will login as default "vagrant" user.

I'm not sure is it a bug or missing configuration by me.

Packer version: 1.5.4
Host: Windows 1909
VirtualBox version: 6.1.4

Thank you!

buildevagrant question

Most helpful comment

I've got a PR open with a fix -- @joshuadoss's suggestion is correct and will work after this PR is merged. Binaries of that branch can be found at https://circleci.com/gh/hashicorp/packer/36144#artifacts/containers/0

All 8 comments

@acikogun Try removing the ssh_* directives from your configuration, add "communicator": "ssh", to the builder block, and try again.

I've already tried that before this configuration. It throws the same error.

I have this same basic issue. I can login to the source box with
vagrant ssh source with in the output-vagrant directory and the vagrant ssh-config source command outputs the correct information for the login process.

This seems to be a packer here are my version:

Packer: 1.5.4
Host: Mac OS : Darwin Kernel Version 17.7.0
Virtual Box: 6.1.4

Here is the output of vagrant ssh-config source

vagrant ssh-config source
Host source
HostName 127.0.0.1
User vagrant
Port 2201
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/XXX/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL

I can confirm that this is a regression in v1.5.2 and higher. Working on a fix now.

I've got a PR open with a fix -- @joshuadoss's suggestion is correct and will work after this PR is merged. Binaries of that branch can be found at https://circleci.com/gh/hashicorp/packer/36144#artifacts/containers/0

It works now. Thank you!

Fixed for Darwin/Mac OS as well. thank you for the very quick fix on this.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings