2020-12-25 13:35:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# @see https://stackoverflow.com/questions/32408820/how-to-list-files-and-match-first-line-in-bash-script
|
|
|
|
# @see https://unix.stackexchange.com/questions/298590/using-find-non-recursively
|
|
|
|
# @see https://security.stackexchange.com/questions/129724/how-to-check-if-an-ssh-private-key-has-passphrase-or-not
|
2020-12-25 13:49:03 +01:00
|
|
|
find "$HOME/.ssh" -maxdepth 1 -type f -print0 | while IFS= read -r -d $'\0' file; do
|
2020-12-25 13:35:44 +01:00
|
|
|
if [[ $(head -n1 "$file") == "-----BEGIN OPENSSH PRIVATE KEY-----" ]]; then
|
|
|
|
echo "Test file: $file"
|
2020-12-25 13:49:03 +01:00
|
|
|
ssh-keygen -y -P "" -f "$file"
|
2020-12-25 13:35:44 +01:00
|
|
|
fi
|
|
|
|
done
|