いくつかのサーバーでauthorized_keys
ファイルを監査し、それらを既知のAWSキーフィンガープリントと照合したいと思います。
ssh-keygen -lf
ファイル内のすべてのキーのフィンガープリントを改行付きのニースリストに出力するauthorized_keys
を組み込んだワンライナーはありますか?
から serverfault :
.bashrcで簡単に関数にすることができます。
function fingerprints() {
local file="$1"
while read l; do
[[ -n $l && ${l###} = $l ]] && ssh-keygen -l -f /dev/stdin <<<$l
done < $file
}
そして、次のことを行います。
$ fingerprints .ssh/authorized_keys
どうぞ:
find /path/to/keys/directory -type f -name "*.pub" -exec ssh-keygen -lf {} \; | awk '{print $2}'
編集:おっと、わかりました。今すぐ入手してください。
どうぞ:
while read line; do ssh-keygen -lf "$line"; done < <(cat authorised_keys_file)
(このファイルに1行に1つのキーがある場合)