Packer HCL, vsphere-iso, waiting for ssh

Hi Folks,

Did anybody try packer with HCL and vsphere-iso builder? I’m testing a new config (below) with default centos iso

source "vsphere-iso" "default" {
    vcenter_server      = var.vcenter_server
    username            = var.username
    password            = var.password
    insecure_connection = true
    cluster             = var.cluster
    datacenter          = var.datacenter
    host                =  # w/o host it doesn't work. I think there is a bug opened in GH to fix that. 
    datastore           = var.datastore
    iso_urls          = [var.iso_urls]
    iso_checksum      = var.iso_checksum
    iso_checksum_type = "sha256"
    vm_name               = "packer_tml_jbl_${ var.image_os }_std_{{ isotime \"2006-01-02\" }}"
    guest_os_type         = var.guest_os_type
    disk_thin_provisioned = true
    disk_size             = 45000
    network_card          = "vmxnet3"
    network               = "VM Network"
    CPUs                  = 2
    cpu_cores             = 2
    CPU_hot_plug          = true
    RAM                   = 4096
    RAM_hot_plug          = true
    floppy_files = [
    boot_command = ["<tab> initrd=initrd.img net.ifnames=0 biosdevname=0 inst.text ksdevice=eth0 inst.ks=hd:fd0:/ks-centos.cfg <enter><wait>"]
    ssh_username = "root"
    ssh_password = "${var.ssh_password}"
    ssh_timeout  = "10m"!
    shutdown_command = "echo 'packer' | sudo -S /sbin/halt -h -p"

build {
  sources = [
  provisioner "shell" {
    execute_command = "echo 'packer' | {{ .Vars }} sudo -S -E bash '{{ .Path }}'"
    scripts = [

It looks like packer can’t authenticate via ssh (username and pass). When I try to connect to the VM via ssh with same creds, it works fine.

packer -version

packer log:

2020/04/13 14:23:19 packer.exe plugin: [INFO] Attempting SSH connection to
2020/04/13 14:23:19 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2020/04/13 14:23:19 packer.exe plugin: [DEBUG] handshaking with SSH
2020/04/13 14:23:21 packer.exe plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2020/04/13 14:23:21 packer.exe plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.

ks.cfg (short version)

repo --name="CentOS" --baseurl=$releasever/os/$basearch/ --cost=100
lang en_US
keyboard us
# Root password 
rootpw --iscrypted <our encrypted pass her> 
# Use text mode install
# System authorization information
auth  --useshadow  --passalgo=sha512
# Firewall configuration
firewall --enabled --ssh
selinux --permissive
logging --level=info
network --device enp0s3 --bootproto dhcp
timezone --utc America/New_York
# Reboot after installation
reboot --eject
@core --nodefaults
%addon com_redhat_kdump --disable
%post --log=/var/log/ks.post02.log
# Install sdc-vmtools guest tools
# required to detect IP when building on ESXi
echo "Installing VM Tools..."
sudo yum -y install open-vm-tools
sudo systemctl enable vmtoolsd
sudo systemctl start vmtoolsd

As in most of such cases, the issues was with ks.cfg. I don’t know why it allowed to ssh with the same password via native ssh but packer couldn’t.

Anyway, as soon as I re-created the encrypted password, it started to work.

1 Like