diff --git a/deploy.pl b/deploy.pl index af7e2b2..55805a4 100755 --- a/deploy.pl +++ b/deploy.pl @@ -23,6 +23,7 @@ # 2019/05/31 added: check for OpenBSD 6.6 vmctl command line syntax change # 2019/09/29 added: doas.conf for pkill option # 2020/05/10 changed: includes all install sets, inline with sysupgrade +# 2020/05/22 changed: set the hosts password for the user # use 5.024; use strict; @@ -53,7 +54,7 @@ sub get_variables { open my $fh, "<", "$file"; while (my $row = <$fh>) { next if ($row =~ /^\s*($|#)/); - chomp ($row); + chomp($row); (my $key, my $val) = split(/=/, $row, 2); if ($hash_name eq "vms") { ($hash{$vm_name}{$key} .= $val) =~ s/^"+|"+$//g; @@ -172,7 +173,7 @@ sub render_install_conf { if (! -e $_disk) { my $_hostname = $vms{$vm_name}{'hostname'}; my $_pass = qx(jot -rcs '' 20 33 126); - chomp ($_pass); + chomp($_pass); my $_ipv6 = $conf{'conf'}{'IPV6_PREFIX'} . ":" . ($conf{'conf'}{'IPV6_START'} + $vms{$vm_name}{'vm_number'}) . "::" . ($conf{'conf'}{'IP_START'} + $vms{$vm_name}{'vm_number'}); my $_ipv6_gateway = $conf{'conf'}{'IPV6_PREFIX'} . ":" . ($conf{'conf'}{'IPV6_START'} + $vms{$vm_name}{'vm_number'}) . "::1"; my $_username = $vms{$vm_name}{'username'}; @@ -239,9 +240,13 @@ sub create_accounts { my $id = getpwnam("$_owner"); if (! $id) { - my $output = qx(/usr/sbin/useradd -m -G $_group $_owner); + my $_pass = qx(jot -rcs '' 20 39 126); + chomp($_pass); + my $_encrypted_pass = qx(encrypt $_pass); + chomp($_encrypted_pass); + my $output = qx(/usr/sbin/useradd -m -G $_group -p "$_encrypted_pass" $_owner); open my $fh_authorized, ">>", "/home/$_owner/.ssh/authorized_keys"; - printf $fh_authorized "%s\n", $_sshkey; + printf $fh_authorized "%s %s\n", $_sshkey, $_pass; close $fh_authorized; printf "%16s %s account created\n", $_instance, $_owner; }