Skip to content
Snippets Groups Projects
Commit 809b4f86 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

allow older version of ssh-keygen

parent cc4a374b
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,9 @@
use strict;
my ($version, $has_E)= get_ssh_version();
my $hash_algorithm= 'MD5';
my @files= <*.pub>;
# print "files: ", join (' ', @files), "\n";
push (@files, <authorized_keys*>);
......@@ -19,7 +22,10 @@ push (@files, <authorized_keys*>);
printf ("%-20s %5s %-51s %-6s %s\n", qw(file size fingerprint type notes));
foreach my $file (@files)
{
my @cmd= (qw(ssh-keygen -lE md5 -f), $file);
my @cmd= qw(ssh-keygen -l);
push (@cmd, '-E', $hash_algorithm) if ($has_E);
push (@cmd, '-f', $file);
my $res= `@cmd`;
my @lines= split ("\n", $res);
foreach my $line (@lines)
......@@ -28,9 +34,28 @@ foreach my $file (@files)
my $type= 'unknown';
if ($notes =~ m#(.+)\s+\((.+)\)#) { ($notes, $type)= ($1, $2) }
$fp= join(':', $hash_algorithm, $fp) unless ($has_E);
printf ("%-20s %5d %-51s %-6s %s\n", $file, $size, $fp, $type, $notes);
}
}
printf ("%-20s %5d %s %-6s %s\n", $file, $size, $fp, $type, $notes);
sub get_ssh_version
{
my @cmd= qw(ssh-keygen --version); # apparently, there is way to display the version directly
my $res= `@cmd 2>&1`;
my $version= 'unknown';
my $has_E= 0;
foreach my $l (split ("\n", $res))
{
# print "[$l]\n";
if ($l =~ ' -L Print the contents of a certificate.') { $has_E= 0; }
elsif ($l eq ' ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile]') { $has_E= 1; }
}
($version, $has_E);
}
=head1 TODO
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment