Created
December 14, 2021 11:43
-
-
Save Esonhugh/d3bbdfb413fd8494dd9709a4fe2be237 to your computer and use it in GitHub Desktop.
Is the sshkey same?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SGTM