Enable SSH password authentication in cloned vSphere CentOS 7 VM

Hello,

I need help for this: the VM cloned from a vSphere CentOS template does not come with the SSH password authentication enabled, so that I can not SSH to the machine for configuration.

I already edited /etc/ssh/sshd_config in the Template using

sed -i "s/Password Authentication no/PasswordAuthentication yes/g"

so the conf file should be fine.

The problem is that no change is applied to the conf file of the cloned machine. If I have a look at the conf file, the PasswordAuthentication field is still mysteriously set to no.

This really impacts my automation worflow, what am I doing wrong? Am I missing something?

Thank you in advance!

1 Like

I have the same issue! no clue what’s going on here. somehow the VM recognizes that’s is cloned and resets the PassowrdAuthentication field…

Hi there!
I ran into the same problem.
Did a bit of research:

in the VM created from the packer image:

  1. PRETTY_NAME="Oracle Linux Server 8.10

cloud-init status --long
status: done
extended_status: done
boot_status_code: enabled-by-generator
last_update: Mon, 03 Feb 2025 12:11:27 +0000
Detail:
DataSourceVMware [seed=imc].
Error: []
recoverable_errors: {}
grep -i password /var/log/cloud-init.log
2025-02-03 12:11:26,928 - ssh_util.py[DEBUG]: line 71: option PasswordAuthentication updated yes -> no

I found https://cloudinit.readthedocs.io/en/latest/reference/modules.html#set-passwords

This is what I found:

grep -R ssh_pwauth /etc/cloud/
/etc/cloud/cloud.cfg:ssh_pwauth: false

changed in the packer like this
sed -i 's/ssh_pwauth: false/ssh_pwauth: true/g' /etc/cloud/cloud.cfg
and at the end of the packer script I did
sudo cloud-init clean

Now the parameter doesn’t change when cloning the VM.