Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Created August 17, 2010 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mschmitt/529388 to your computer and use it in GitHub Desktop.
Save mschmitt/529388 to your computer and use it in GitHub Desktop.
Script for identifying SSH keys without passphrase
#!/bin/bash
umask 077
if [ "XX$1" == "XX" ]
then
echo "No file specified."
exit 1
fi
if [ ! -e $1 ]
then
echo "File not found: $1"
exit 1
fi
KEYFILE=$1
TEMPFILE=$(mktemp)
cp $KEYFILE $TEMPFILE
ssh-keygen -p -P '' -N 123456789 -f $TEMPFILE >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
echo "$KEYFILE - contains an unprotected OpenSSH key"
else
echo "$KEYFILE - does not contain an unprotected OpenSSH key"
fi
rm $TEMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment