diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2013-10-07 06:25:39 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-06-07 04:27:26 +0200 |
commit | 56c9372d22859203caf7dcabf271896ddf9e216c (patch) | |
tree | 0e09455878e5f84e02ec5e303b5f2286d5ffa81a /sshfprs.sh | |
parent | a64e8005a6bc0004c77a2baff8b28e3a0f031e8e (diff) |
Factorization: Separate the logic from the text.
Diffstat (limited to 'sshfprs.sh')
-rwxr-xr-x | sshfprs.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sshfprs.sh b/sshfprs.sh new file mode 100755 index 0000000..83cebd9 --- /dev/null +++ b/sshfprs.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Like ssh-keygen -lf, but for a file such as authorized_keys, which +# may contain multiple keys. +# +# Usage: sshfprs.sh file [prefix] + +set -ue + +file="$1" +prefix="${2:-}" + +while read pk; do + # ssh-keygen can't read from STDIN, and ash doesn't have the '<<<' + # construct, so we save each pubkey in a temporary file + pkf=$(mktemp) + echo "$pk" > "$pkf" + echo "${prefix}$(ssh-keygen -lf $pkf)" + rm "$pkf" +done < "$file" |