Skip to content

Instantly share code, notes, and snippets.

@Esonhugh
Created December 14, 2021 11:43
Show Gist options
  • Save Esonhugh/d3bbdfb413fd8494dd9709a4fe2be237 to your computer and use it in GitHub Desktop.
Save Esonhugh/d3bbdfb413fd8494dd9709a4fe2be237 to your computer and use it in GitHub Desktop.
Is the sshkey same?
# Author: Esonhugh
# Date: 2021/12/14 19:43 UTC+0800
function isSameSSHKEY () {
PRIVKEY=$1
TESTKEY=$2
if [[ -z "$PRIVKEY" ]]
then
PRIVKEY="id_rsa"
echo "No PRIVKEY chosen Set as id_rsa"
fi
if [[ -z "$TESTKEY" ]]
then
TESTKEY="$PRIVKEY.pub"
echo "No PUBKEY chosen Set as $PRIVKEY.pub"
fi
echo "PRIKEY is $PRIVKEY "
echo "PUBKEY is $TESTKEY"
echo ""
echo "diff command runs ....."
diff --color=auto <( ssh-keygen -y -e -f "$PRIVKEY" ) <( ssh-keygen -y -e -f "$TESTKEY" )
if [[ $? -eq 0 ]]
then
echo "success! is same!"
else
echo "bad! not matched!"
fi
}
@william2ai
Copy link

SGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment