From b50a93e8a76dd02517206bf5209127c22253c74b Mon Sep 17 00:00:00 2001 From: Gerhard Gonter <ggonter@gmail.com> Date: Tue, 28 Nov 2017 14:47:44 +0100 Subject: [PATCH] allow option -E to specify hash algorithm --- show_fingerprints.pl | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/show_fingerprints.pl b/show_fingerprints.pl index 9e3ffed..766080d 100755 --- a/show_fingerprints.pl +++ b/show_fingerprints.pl @@ -16,7 +16,32 @@ my ($version, $has_E)= get_ssh_version(); my $hash_algorithm= 'MD5'; my @files= <*.pub>; -push @files, @ARGV if (@ARGV); + +while (my $arg= shift (@ARGV)) +{ + if ($arg eq '--') {} + elsif ($arg =~ m#^--(.+)#) + { + } + elsif ($arg =~ m#^-(.+)#) + { + print ">>> arg=[$arg] 1=[$1]\n"; + my @opts= split ('', $1); + foreach my $opt (@opts) + { + if ($opt eq 'E') + { + $has_E= 1; + $hash_algorithm= shift (@ARGV); + print "NOTE: hash_algorithm=[$hash_algorithm]\n"; + } + } + } + else + { + push (@files, $arg); + } +} # print "files: ", join (' ', @files), "\n"; push (@files, <authorized_keys*>); @@ -27,6 +52,7 @@ foreach my $file (@files) my @cmd= qw(ssh-keygen -l); push (@cmd, '-E', $hash_algorithm) if ($has_E); push (@cmd, '-f', $file); + # print "cmd: [", join (' ', @cmd), "\n"; my $res= `@cmd`; my @lines= split ("\n", $res); -- GitLab