## TITLE: SSH - HOW TO TEST AN SSH KEY PAIR (FINGERPRINT TEST) ## OS: BASH / SSH ## LAST DOC MODIFY: 2011-11-18 #!/bin/bash clear svr_name=`/usr/bin/whoami` tgt_ip="192.0.1.50" tgt_usr="$svr_name@$tgt_ip" ## CHECKING FINGERPRINTS ##################################### echo "" echo "---------- CHECKING FINGERPRINTS" finger_pri=`ssh-keygen -lf ~/.ssh/id_dsa | awk '{print $2}'` finger_pub=`ssh $tgt_usr "ssh-keygen -lf .ssh/authorized_keys2" | awk '{print $2}'` if [[ "$finger_pri" != "$finger_pub" ]]; then echo "" echo "---------- WARNING: FINGERPRINTS DONT MATCH" echo "" exit 3 elif [[ "$finger_pri" == "$finger_pub" ]]; then echo "" echo "---------- FINGERPRINTS MATCH" echo "" fi # __________________________________________________________________________________________ # Copyright 2000-2011 Dylan Schneider. All Rights Reserved. # This document uses unix line breaks(LF). # Text on macnode.com is for example only, not as actual working instructions. # Text on macnode.com should only be used as a guide, and only by advanced it professionals.