]> git.proxmox.com Git - pve-container.git/commitdiff
fix #1253: display SSH fingerprints on CT setup
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 17 Jan 2017 13:12:34 +0000 (14:12 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 18 Jan 2017 10:08:30 +0000 (11:08 +0100)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/LXC/Setup.pm

index b9e112b48b3eddab452a3e9f2c56918f86cdc39f..1baeaa249f2618f85df29f4864f7266538031240 100644 (file)
@@ -218,17 +218,24 @@ sub rewrite_ssh_host_keys {
 
     my $hostname = $conf->{hostname} || 'localhost';
     $hostname =~ s/\..*$//;
+    my $ssh_comment = "root\@$hostname";
 
-    # Create temporary keys in /tmp on the host
+    my $keygen_outfunc = sub {
+       my $line = shift;
+
+       print "done: $line\n"
+           if ($line =~ m/^([0-9a-f]{2}:)+[0-9a-f]{2}\s+\Q$ssh_comment\E$/i);
+    };
 
+    # Create temporary keys in /tmp on the host
     my $keyfiles = {};
     foreach my $keytype (keys %$keynames) {
        my $basename = $keynames->{$keytype};
        my $file = "/tmp/$$.$basename";
        print "Creating SSH host key '$basename' - this may take some time ...\n";
-       my $cmd = ['ssh-keygen', '-q', '-f', $file, '-t', $keytype,
-                  '-N', '', '-C', "root\@$hostname"];
-       PVE::Tools::run_command($cmd);
+       my $cmd = ['ssh-keygen', '-f', $file, '-t', $keytype,
+                  '-N', '', '-C', $ssh_comment];
+       PVE::Tools::run_command($cmd, outfunc => $keygen_outfunc);
        $keyfiles->{"/etc/ssh/$basename"} = [PVE::Tools::file_get_contents($file), 0600];
        $keyfiles->{"/etc/ssh/$basename.pub"} = [PVE::Tools::file_get_contents("$file.pub"), 0644];
        unlink $file;