There are two problems that (perhaps together) result in network not working in CentOS (and hence SSH not working, although we can connect to the VM using the virsh console command):
The file /etc/sysconfig/network-scripts/ifcfg-eth0 refers to eth0 while device name is ens4.
systemd-networkd is not pre-installed in CentOS, so the network-0.network systemd unit file does not configure the network.
The ifcfg-ens4 file can be updated using user_data write_files section, but that happens after network configuration, so the network is not properly configured on first boot.
There are two problems that (perhaps together) result in network not working in CentOS (and hence SSH not working, although we can connect to the VM using the
virsh console
command):/etc/sysconfig/network-scripts/ifcfg-eth0
refers toeth0
while device name isens4
.systemd-networkd
is not pre-installed in CentOS, so thenetwork-0.network
systemd unit file does not configure the network.The
ifcfg-ens4
file can be updated using user_datawrite_files
section, but that happens after network configuration, so the network is not properly configured on first boot.