1
0
mirror of synced 2026-02-02 22:41:03 +00:00

Report all SSH fingerprints of the created DomU, not only RSA one

This commit is contained in:
Axel Beckert
2015-07-04 01:02:34 +02:00
parent ff87729cfe
commit 6b82585cc1
2 changed files with 27 additions and 9 deletions

View File

@@ -797,6 +797,7 @@ use Env;
use File::Path qw/ mkpath /;
use File::Temp qw/ tempdir /;
use File::Copy qw/ mv cp /;
use File::Slurp;
use File::Which;
use Getopt::Long;
use Pod::Usage;
@@ -4119,21 +4120,35 @@ END
exit $exitcode if $VERSION || $HELP || $MANUAL || $DUMPCONFIG;
my $host_rsa_key = '';
my %host_key = ();
#
# Unmount the image if it is still mounted.
#
if ( defined($MOUNT_POINT) )
{
#
# Before we unmount get the host's RSA key
# Before we unmount get the host's SSH keys' fingerprints
#
my $key_path .= $MOUNT_POINT;
$key_path .= '/etc/ssh/ssh_host_rsa_key.pub';
if ( `ssh-keygen -lf $key_path` =~ /^(\S+)\s+(\S+)/ ) {
$host_rsa_key = $2;
} else {
$host_rsa_key = "N/A";
my $key_dir = $MOUNT_POINT.'/etc/ssh';
my @pubkey_files =
grep { /^ssh_host_.*\.pub$/; } read_dir($key_dir);
foreach my $pubkey_file (@pubkey_files) {
my $pubkey_path = "$key_dir/$pubkey_file";
my $fingerprint_line = `ssh-keygen -lf "$pubkey_path"`;
if ($fingerprint_line =~ /^(\S+)\s+(\S+)/ ) {
my $fingerprint = $2;
my $algo = '[unspecified hashing algorithm]';
if ($fingerprint_line =~ /^\S+\s+\S+\s+\S+\s+\((\S+)\)/ ) {
$algo = $1;
} elsif ($pubkey_file =~ /^ssh_host_(\S+)_key\.pub$/) {
$algo = uc($1);
} elsif ($pubkey_file eq 'ssh_host_key.pub') {
$algo = 'SSH1';
}
$host_key{$algo} = $fingerprint;
} else {
warn "Can't parse ssh-keygen output: $fingerprint_line";
}
}
unMountImage($MOUNT_POINT, $CONFIG{'FAIL'});
}
@@ -4249,7 +4264,9 @@ END
logprint( $IP_ADDRESSES );
}
logprint("\n");
logprint("RSA Fingerprint : $host_rsa_key\n");
foreach my $algo (sort keys %host_key) {
logprint("SSH Fingerprint : $host_key{$algo} ($algo)\n");
}
logprint("Root Password : ");
if ( $PASSWORD ) {
logprint("$PASSWORD\n");