When passing a yescrypt hashed password to a cloud-init kvm, the value gets rehashed into a sha256crypt, instead of passing the yescrypt hash directly, as it does with sha512crypt hashes.
Seems to be due to code not recognising the "$y$j9T$...." as an hashed password, for example in PVE/API2/Qemu.pm(1655):
Examples, with password set to
- yescrypt;
- sha512crypt;
Seems to be due to code not recognising the "$y$j9T$...." as an hashed password, for example in PVE/API2/Qemu.pm(1655):
Code:
...
my $skip_cloud_init = extract_param($param, 'skip_cloud_init');
if (defined(my $cipassword = $param->{cipassword})) {
# Same logic as in cloud-init (but with the regex fixed...)
$param->{cipassword} = PVE::Tools::encrypt_pw($cipassword)
if $cipassword !~ /^\$(?:[156]|2[ay])(\$.+){2}/;
}
my @paramarr = (); # used for log message
...
Examples, with password set to
test1234
:- yescrypt;
$y$j9T$IDqZPRj3QPlrdR3KR0fff/$.hJ0ZpcYXa5uYRPLwtuukcWfIlz7kpCZ40qeKyt6VCA
:
Code:
mklapwijk@qemu-01:~$ sudo cat /var/lib/cloud/instance/user-data.txt
#cloud-config
hostname: qemu-01
manage_etc_hosts: true
fqdn: qemu-01.domain.tld
user: test
password: $5$Q61/b6VR$rx91IPdOy0jWi6LKsDn1TptP7TKutIC/5BohLYIvi9D
chpasswd:
expire: False
users:
- default
package_upgrade: true
- sha512crypt;
$6$xJzA.dbF1ZP.I6Yj$nz9MNnHZv6fs8qdfwp88X4HmcDvtdp8K48tSZW9uWFhlELSZKzxktHfuquYYJBSHd9zgJKL.H8EAYhSlr8U3P/
:
Code:
test@qemu-01:~$ sudo cat /var/lib/cloud/instance/user-data.txt
#cloud-config
hostname: qemu-01
manage_etc_hosts: true
fqdn: qemu-01.domain.tld
user: test
password: $6$xJzA.dbF1ZP.I6Yj$nz9MNnHZv6fs8qdfwp88X4HmcDvtdp8K48tSZW9uWFhlELSZKzxktHfuquYYJBSHd9zgJKL.H8EAYhSlr8U3P/
chpasswd:
expire: False
users:
- default
package_upgrade: true
Last edited: