#!/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"