Site Tools


Hotfix release available: 2025-05-14b "Librarian". upgrade now! [56.2] (what's this?)
Hotfix release available: 2025-05-14a "Librarian". upgrade now! [56.1] (what's this?)
New release available: 2025-05-14 "Librarian". upgrade now! [56] (what's this?)
comparekeys.sh
compare_keys.sh
#!/bin/bash
 
## Little script to see if a public key and private key
## match one another. Assumes keys are in ~/.ssh/ directory
## and that the pubkey is <privkey_name>.pub
 
# usage:  ./compare_keys privkey_name
 
 
if [ "$#" -ne 1 ]; then
    echo "Invalid arguments"
    exit
fi
 
PRIVKEY=$1
PUBKEY="$PRIVKEY.pub"
OUTPUT=`diff -q <(ssh-keygen -y -e -f ~/.ssh/$PRIVKEY) <( ssh-keygen -y -e -f ~/.ssh/$PUBKEY )`
if [ -z "$OUTPUT" ]; then
    echo "Match"
else
    echo "No Match!!"
fi
comparekeys.sh.txt · Last modified: 2024/10/06 10:27 by 127.0.0.1