Overview of the Issue
When building Ubuntu images, ansible failed to connect to the VM with ssh with the following error:
Failed to connect to the host via ssh: Unable to negotiate with 127.0.0.1 port 38741: no matching host key type found. Their offer: ssh-rsa
Reproduction Steps
Command to run
packer build \ -force -on-error=ask \ --only vsphere-iso.linux-ubuntu \ -var-file="config/vsphere.pkrvars.hcl" \ -var-file="config/ansible.pkrvars.hcl" \ -var-file="config/build.pkrvars.hcl" \ -var-file="config/common.pkrvars.hcl" \ builds/linux/ubuntu/22-04-lts
Packer Version
Packer 1.8.0
Plugin Version and Builders
vsphere-plugin 1.0.4
Builder: builds/linux/ubuntu/18-04-lts/linux-ubuntu.pkr.hcl
VMware vSphere Version
VMware vSphere version: 7.0.2
Guest Operating System
Ubuntu 22.04 LTS x64
Ubuntu 18.04 LTS x64
Simplified Packer Buildfile
No change on the build file
Operating System and Environment Details
Kali Linux on wsl2
Log Fragments and crash.log Files
2022/05/26 01:23:47 packer-provisioner- plugin: -playbook version: 2.12.4
2022/05/26 01:23:47 ui: ==> vsphere-iso.linux-ubuntu: Provisioning with Ansible...
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: Setting up proxy adapter for Ansible....
2022/05/26 01:23:47 packer-provisioner- plugin: Creating inventory file for Ansible run...
2022/05/26 01:23:47 packer-provisioner- plugin: SSH proxy: serving on 127.0.0.1:38067
2022/05/26 01:23:47 ui: ==> vsphere-iso.linux-ubuntu: Executing Ansible: -playbook -e packer_build_name="linux-ubuntu" -e packer_builder_type=vsphere-iso -e packer_http_addr=172.30.105.111:0 --ssh-extra-args '-o IdentitiesOnly=yes' --extra-vars display_skipped_hosts=false --extra-vars BUILD_USERNAME= --extra-vars BUILD_SECRET=***** --extra-vars ANSIBLE_USERNAME= --extra-vars ANSIBLE_SECRET=***** -e _ssh_private_key_file=/tmp/-key3651137202 -i /tmp/packer-provisioner-2855013751 /tmp/packer-examples-for-vsphere//main.yml
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: [DEPRECATION WARNING]: COMMAND_WARNINGS option, the command warnings feature is
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: being removed. This feature will be removed from -core in version 2.14.
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: Deprecation warnings can be disabled by setting deprecation_warnings=False in
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: .cfg.
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: PLAY [all] *********************************************************************
2022/05/26 01:23:48 packer-provisioner- plugin: SSH proxy: accepted connection
2022/05/26 01:23:48 ui error: ==> vsphere-iso.linux-ubuntu: failed to handshake
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: TASK [Gathering Facts] *********************************************************
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Unable to negotiate with 127.0.0.1 port 38067: no matching host key type found. Their offer: ssh-rsa", "unreachable": true}
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: PLAY RECAP *********************************************************************
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: default : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 packer-provisioner- plugin: shutting down the SSH proxy
2022/05/26 01:23:48 [INFO] (telemetry) ending
2022/05/26 01:23:48 ui error: ==> vsphere-iso.linux-ubuntu: Error executing Ansible: Non-zero exit status: exit status 4
Overview of the Issue
When building Ubuntu images, ansible failed to connect to the VM with ssh with the following error:
Failed to connect to the host via ssh: Unable to negotiate with 127.0.0.1 port 38741: no matching host key type found. Their offer: ssh-rsaReproduction Steps
Command to run
packer build \ -force -on-error=ask \ --only vsphere-iso.linux-ubuntu \ -var-file="config/vsphere.pkrvars.hcl" \ -var-file="config/ansible.pkrvars.hcl" \ -var-file="config/build.pkrvars.hcl" \ -var-file="config/common.pkrvars.hcl" \ builds/linux/ubuntu/22-04-ltsPacker Version
Packer 1.8.0
Plugin Version and Builders
vsphere-plugin 1.0.4
Builder: builds/linux/ubuntu/18-04-lts/linux-ubuntu.pkr.hcl
vsphere-isovsphere-cloneVMware vSphere Version
VMware vSphere version: 7.0.2
Guest Operating System
Ubuntu 22.04 LTS x64
Ubuntu 18.04 LTS x64
Simplified Packer Buildfile
No change on the build file
Operating System and Environment Details
Kali Linux on wsl2
Log Fragments and
crash.logFiles2022/05/26 01:23:47 packer-provisioner- plugin: -playbook version: 2.12.4
2022/05/26 01:23:47 ui: ==> vsphere-iso.linux-ubuntu: Provisioning with Ansible...
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: Setting up proxy adapter for Ansible....
2022/05/26 01:23:47 packer-provisioner- plugin: Creating inventory file for Ansible run...
2022/05/26 01:23:47 packer-provisioner- plugin: SSH proxy: serving on 127.0.0.1:38067
2022/05/26 01:23:47 ui: ==> vsphere-iso.linux-ubuntu: Executing Ansible: -playbook -e packer_build_name="linux-ubuntu" -e packer_builder_type=vsphere-iso -e packer_http_addr=172.30.105.111:0 --ssh-extra-args '-o IdentitiesOnly=yes' --extra-vars display_skipped_hosts=false --extra-vars BUILD_USERNAME= --extra-vars BUILD_SECRET=***** --extra-vars ANSIBLE_USERNAME= --extra-vars ANSIBLE_SECRET=***** -e _ssh_private_key_file=/tmp/-key3651137202 -i /tmp/packer-provisioner-2855013751 /tmp/packer-examples-for-vsphere//main.yml
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: [DEPRECATION WARNING]: COMMAND_WARNINGS option, the command warnings feature is
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: being removed. This feature will be removed from -core in version 2.14.
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: Deprecation warnings can be disabled by setting deprecation_warnings=False in
2022/05/26 01:23:47 ui: vsphere-iso.linux-ubuntu: .cfg.
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: PLAY [all] *********************************************************************
2022/05/26 01:23:48 packer-provisioner- plugin: SSH proxy: accepted connection
2022/05/26 01:23:48 ui error: ==> vsphere-iso.linux-ubuntu: failed to handshake
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: TASK [Gathering Facts] *********************************************************
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Unable to negotiate with 127.0.0.1 port 38067: no matching host key type found. Their offer: ssh-rsa", "unreachable": true}
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: PLAY RECAP *********************************************************************
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu: default : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
2022/05/26 01:23:48 ui: vsphere-iso.linux-ubuntu:
2022/05/26 01:23:48 packer-provisioner- plugin: shutting down the SSH proxy
2022/05/26 01:23:48 [INFO] (telemetry) ending
2022/05/26 01:23:48 ui error: ==> vsphere-iso.linux-ubuntu: Error executing Ansible: Non-zero exit status: exit status 4