Packer can't establish an SSH connection with the guest

4,127 views
Skip to first unread message

bour...@etna-alternance.net

unread,
Apr 27, 2016, 9:05:44 AM4/27/16
to Packer
I'm trying to build a vagrant box from an installation (from ISO) of a custom FreeBSD on VirtualBox, but packer has difficulty to end the build because of the SSH connection which fails.

Here is my .json :

{
   
"variables": {
 
"ssh_name": "admin",
 
"ssh_pass": "admin",
 
"ip": "10.0.1.1",
 
"netmask": "255.255.0.0",
 
"gateway": "10.0.0.254"
   
},
   
"builders": [{
 
"type": "virtualbox-iso",
 
"headless": "true",


 
"vboxmanage": [
   
["modifyvm", "{{.Name}}", "--acpi", "on"],
   
["modifyvm", "{{.Name}}", "--ioapic", "on"],
   
["modifyvm", "{{.Name}}", "--longmode", "on"],
   
["modifyvm", "{{.Name}}", "--cpus", "1"],
   
["modifyvm", "{{.Name}}", "--memory", "2048"],
   
["modifyvm", "{{.Name}}", "--vram", "9"],
   
["modifyvm", "{{.Name}}", "--nic1", "bridged"],
   
["modifyvm", "{{.Name}}", "--bridgeadapter1", "net2"],
   
["modifyvm", "{{.Name}}", "--vrde", "on"],
   
["modifyvm", "{{.Name}}", "--vrdeaddress", "10.0.250.10"]
 
],
 
"vrdp_port_min": 42000,
 
"vrdp_port_max": 42100,


 
"disk_size": 16000,


 
"guest_os_type": "FreeBSD_64",
 
"guest_additions_mode": "disable",
 
 
"iso_url": "/mnt//ISO/my.iso",
 
"iso_checksum": "972fb9aff8403075ad69994ea50cef3e",
 
"iso_checksum_type": "md5",


 
"ssh_skip_nat_mapping": "true",
 
"ssh_host": "{{user `ip`}}",
 
"ssh_port": 22,
 
"ssh_username": "{{user `ssh_name`}}",
 
"ssh_password": "{{user `ssh_pass`}}",
 
"ssh_wait_timeout": "15m",


 
"shutdown_command": "echo {{user `ssh_pass`}} | sudo -S shutdown -P now",


 
"boot_wait" : "10s",
 
"boot_command" : [
 
"<enter><wait10><wait10><left><enter><wait10><wait10>",
 
"<wait10><wait10><wait10><wait10><wait10><wait10><wait10><wait10><wait10>",
 
"<wait10><wait10><wait10><wait10><wait10><wait10><wait10>",
 
"{{user `ssh_name`}}",
 
"<wait><enter>",
 
"{{user `ssh_pass`}}",
 
"<wait><enter>",
 
"<wait><enter><wait><enter><wait><enter><wait>",
 
"<end><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
 
"{{user `ip`}}<down>",
 
"<end><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
 
"{{user `netmask`}}<down>",
 
"{{user `gateway`}}",
 
"<enter><wait><enter><wait><enter><wait10><wait5><enter>t<enter><enter>"
 
]
   
}],
   
"post-processors": [{
 
"type": "vagrant",
 
"output": "my.box"
   
}]
}

Here is log file (SSH step) :

2016/04/27 10:59:01 packer: 2016/04/27 10:59:01 [INFO] Waiting for SSH, up to timeout: 15m0s
2016/04/27 10:59:01 ui: ==> virtualbox-iso: Waiting for SSH to become available...
2016/04/27 10:59:01 packer: 2016/04/27 10:59:01 [INFO] Attempting SSH connection...
2016/04/27 10:59:01 packer: 2016/04/27 10:59:01 reconnecting to TCP connection for SSH
2016/04/27 10:59:01 packer: 2016/04/27 10:59:01 handshaking with SSH
2016/04/27 10:59:03 packer: 2016/04/27 10:59:03 handshake error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2016/04/27 10:59:03 packer: 2016/04/27 10:59:03 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2016/04/27 10:59:03 packer: 2016/04/27 10:59:03 [DEBUG] Detected authentication error. Increasing handshake attempts.
[...] Same logs x 8
2016/04/27 11:00:22 packer: 2016/04/27 11:00:22 [INFO] Attempting SSH connection...
2016/04/27 11:00:22 packer: 2016/04/27 11:00:22 reconnecting to TCP connection for SSH
2016/04/27 11:00:22 packer: 2016/04/27 11:00:22 handshaking with SSH
2016/04/27 11:00:23 packer: 2016/04/27 11:00:23 handshake error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2016/04/27 11:00:23 packer: 2016/04/27 11:00:23 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2016/04/27 11:00:23 packer: 2016/04/27 11:00:23 [DEBUG] Detected authentication error. Increasing handshake attempts.
2016/04/27 11:00:23 ui error: ==> virtualbox-iso: Error waiting for SSH: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2016/04/27 11:00:23 packer: 2016/04/27 11:00:23 Executing VBoxManage: []string{"controlvm", "packer-virtualbox-iso-1461747242", "poweroff"}
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 stdout:
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 Executing VBoxManage: []string{"storageattach", "packer-virtualbox-iso-1461747242", "--storagectl", "IDE Controller", "--port", "0", "--device", "1", "--medium", "none"}
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 stdout:
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 stderr:
2016/04/27 11:00:24 ui: ==> virtualbox-iso: Unregistering and deleting virtual machine...
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 Executing VBoxManage: []string{"unregistervm", "packer-virtualbox-iso-1461747242", "--delete"}
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 stdout:
2016/04/27 11:00:24 packer: 2016/04/27 11:00:24 stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
2016/04/27 11:00:24 ui: ==> virtualbox-iso: Deleting output directory...
2016/04/27 11:00:24 ui error: Build 'virtualbox-iso' errored: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2016/04/27 11:00:24 Builds completed. Waiting on interrupt barrier...
2016/04/27 11:00:24 machine readable: error-count []string{"1"}
2016/04/27 11:00:24 ui error:
==> Some builds didn't complete successfully and had errors:
2016/04/27 11:00:24 machine readable: virtualbox-iso,error []string{"ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain"}
2016/04/27 11:00:24 ui error: --> virtualbox-iso: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2016/04/27 11:00:24 ui:
==> Builds finished but no artifacts were created.
2016/04/27 11:00:24 waiting for all plugin processes to complete...
2016/04/27 11:00:24 /usr/local/bin/packer: plugin process exited
2016/04/27 11:00:24 /usr/local/bin/packer: plugin process exited

I could connect to the guest via ssh while packer was trying ...
The OS is using x509 certificate, does the problem come from this ?

How packer perform his SSH connection ?
What's the problem ?

Thanks for any help !

Victor

unread,
Apr 27, 2016, 9:20:14 AM4/27/16
to Packer
Hello,

Can you confirm you're able to ssh to the vm via putty ?

Cheers,

Victor
...

bour...@etna-alternance.net

unread,
Apr 27, 2016, 10:49:35 AM4/27/16
to Packer
Like I said, SSH authentication is working well :  
I could connect to the guest via ssh while packer was trying ...

I've performed a network capture via tcpdump, and there is no packet going to destination host 10.0.1.1.
How does packer to establish an SSH connection ? I'm struggling

Alvaro Miranda Aguilera

unread,
Apr 27, 2016, 4:38:03 PM4/27/16
to packe...@googlegroups.com
Hello,

what happens if you comment out the ssh_ip ?

Packer will monitor the dhcp and see what IP is assigned to the vm.

Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/a966d446-57b3-49a7-a2f4-8e087a426da1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bour...@etna-alternance.net

unread,
Apr 28, 2016, 5:48:43 AM4/28/16
to Packer
Hi,

There is no DHCP client on the guest, I only can set a static IP after boot_command step, I've tried "bridged" and "NAT" on NIC without success, packer doesn't find the VM and even the port forwarding is not working.
I wish I could just tell to packer to SSH on the guest like another host on the network.

I've disabled internal Vbox DHCP since I don't need it.

Later after trying to find a solution -> The problem was in the provider layer, Vbox has specific rules to make port forwarding work with NAT : https://www.virtualbox.org/manual/ch06.html#natforward

I'm looking for make it work with bridged adapter :) Awesome !

Thank you very much for your help Alvaro Miranda Aguilera and the hint !
...

Alvaro Miranda Aguilera

unread,
Apr 29, 2016, 4:17:58 AM4/29/16
to packe...@googlegroups.com
Hello,

If you don't want to use the default out of the box virtualbox experience then once the VM get the IP, you can use the null provider.

Can I ask, whats wrong with using the normal virtualbox one?

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

bour...@etna-alternance.net

unread,
Apr 29, 2016, 5:51:06 AM4/29/16
to Packer
Hi Alvaro,

I'm trying to automate the installation and configuration of a DHCP Solution. The guest will be a DHCP server itself, so it could conflict with the internal vbox DHCP server.
Since I will simulate client request, etc. I need to reproduce the exact customer environment, I don't want an additionnal NIC of NAT type.

https://github.com/mitchellh/vagrant/issues/2093 : eth0 as NAT is a fundamental requirement of Vagrant in its current state. Perhaps in the future this limitation can be removed, but for the time being it is required.

It seems to be the case for packer too :/.

Nabil.

Alvaro Miranda Aguilera

unread,
Apr 29, 2016, 11:08:32 AM4/29/16
to packe...@googlegroups.com

bour...@etna-alternance.net

unread,
May 10, 2016, 5:45:57 AM5/10/16
to Packer
Thanks for the help but this is not a solution since I need most of the virtualbox-iso builder features.

I back to a shell script.
Reply all
Reply to author
Forward
0 new messages