RHEL9 SSH handshake err: Timeout during SSH handshake

2023/06/14 11:20:43 packer-1.8.6 plugin: [DEBUG] SSH handshake err: Timeout during SSH handshake
2023/06/14 11:20:50 packer-1.8.6 plugin: [INFO] Attempting SSH connection to 127.0.0.1:2226…
2023/06/14 11:20:50 packer-1.8.6 plugin: [DEBUG] reconnecting to TCP connection for SSH
2023/06/14 11:20:50 packer-1.8.6 plugin: [DEBUG] handshaking with SSH

Base_OS.json
{
“variables”: {
“DVD1”: “/proj/19089-CXP.iso”,
“imagename”: “base_os.qcow2”
},
“builders”:
[
{
“type”: “qemu”,
“accelerator”: “kvm”,
“headless”: true,
“qemuargs”: [
[ “-m”, “8048M” ],
[ “-smp”, “cpus=12,maxcpus=16,cores=8” ]
],
“disk_size”: 30480,
“format”: “qcow2”,
“net_device”: “virtio-net”,

  "iso_url": "{{user `DVD1`}}",
  "iso_checksum_type": "none",

  "vm_name": "{{user `imagename`}}",
  "http_directory": "httpdir",
  "http_port_min": 10082,
  "http_port_max": 10089,

  "ssh_host_port_min": 2222,
  "ssh_host_port_max": 2229,
    "vnc_bind_address": "0.0.0.0",
  "ssh_username": "root",
  "ssh_password": "*****",
  "ssh_port": 22,
  "ssh_wait_timeout": "12000s",
  "boot_wait": "5s",
  "qemuargs":[
[
  "-cpu",
  "host"
]

],
“boot_command”:[
“ inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg ”
],

  "shutdown_command": "shutdown -P now"
}

],
“provisioners”:
[
]
}

ks.cfg
[root@sellics01982 proj]# vi base_os.json
[root@sellics01982 proj]# vi httpdir/ks.cfg
keyboard ‘us’
rootpw EvaiKiO1
lang en_US.UTF-8
network --bootproto=dhcp
firewall --disabled
authselect --enableshadow --passalgo=sha512
cdrom
text
selinux --permissive
reboot
zerombr
clearpart --all --initlabel
autopart
openssh-clients

```plain
Please put your code between tildes like this.
```

And hcl is better than json.

That said, when does the ssh issue occur?

I’m not really familiar with RHEL9 or using kickstart scripts,
as am just waiting for my own issue,
but I do know that 99% of the time an SSH issue occurs to me,
I either did not turn on SSH or didn’t create the username/password
on what I’d like to call either the liveVM or the buildVM, before I do a reboot on either of them.

converted my file into HCL file.
PACKER_LOG=1 ./packer-1.8.6 build --debug base_os.pkr.hcl

still below issue is there:
==> qemu.autogenerated_1: Pausing after run of step ‘stepWaitGuestAddress’. Press enter to continue.
2023/06/20 04:08:43 packer-1.8.6 plugin: [INFO] Waiting for SSH, up to timeout: 3h20m0s
==> qemu.autogenerated_1: Using SSH communicator to connect: 127.0.0.1
==> qemu.autogenerated_1: Waiting for SSH to become available…
2023/06/20 04:08:43 packer-1.8.6 plugin: [INFO] Attempting SSH connection to 127.0.0.1:2222…
2023/06/20 04:08:43 packer-1.8.6 plugin: [DEBUG] reconnecting to TCP connection for SSH
2023/06/20 04:08:43 packer-1.8.6 plugin: [DEBUG] handshaking with SSH
2023/06/20 04:09:43 packer-1.8.6 plugin: [DEBUG] SSH handshake err: Timeout during SSH handshake
2023/06/20 04:09:50 packer-1.8.6 plugin: [INFO] Attempting SSH connection to 127.0.0.1:2222…
2023/06/20 04:09:50 packer-1.8.6 plugin: [DEBUG] reconnecting to TCP connection for SSH
2023/06/20 04:09:50 packer-1.8.6 plugin: [DEBUG] handshaking with SSH
2023/06/20 04:10:50 packer-1.8.6 plugin: [DEBUG] SSH handshake err: Timeout during SSH handshake
2023/06/20 04:10:57 packer-1.8.6 plugin: [INFO] Attempting SSH connection to 127.0.0.1:2222…
2023/06/20 04:10:57 packer-1.8.6 plugin: [DEBUG] reconnecting to TCP connection for SSH
2023/06/20 04:10:57 packer-1.8.6 plugin: [DEBUG] handshaking with SSH
2023/06/20 04:11:57 packer-1.8.6 plugin: [DEBUG] SSH handshake err: Timeout during SSH handshake
2023/06/20 04:12:04 packer-1.8.6 plugin: [INFO] Attempting SSH connection to 127.0.0.1:2222…
2023/06/20 04:12:04 packer-1.8.6 plugin: [DEBUG] reconnecting to TCP connection for SSH
2023/06/20 04:12:04 packer-1.8.6 plugin: [DEBUG] handshaking with SSH

Yes, that’s an ssh issue.
Is this at the end of the boot script, during a reboot or at the end of the last script?

By the end of your boot script your liveVM needs to have SSH enabled and it’s root user’s password needs to be the same as the ssh_password.

Same goes for the buildVM during a reboot, which happens at the end of the script or when you’ve written a reboot into one of your scripts.