3 ms·
There's probably a better way of doing it, but this should check all your public keys if you use more than one, assuming they're in ~/.ssh for file in $(ls ~
by philo23 11y ago
There's probably a better way of doing it, but this should check all your public keys if you use more than one, assuming they're in ~/.ssh
for file in $(ls ~/.ssh/*.pub); do ssh-keygen -lf $file; done
- morganm 11y agoNot better, but could also be written as: find ~/.ssh -name '*.pub' | xargs ssh-keygen -lf Here's a simple bash function to check all your GitHub keys: function check_github_keys { username=$1 i=0 curl -sw "\n" "https://github.com/${username}.keys" | while IFS="\n" read -r line ; do tmp=`mktemp -t githubkey`; echo "$line" > $tmp res=$(ssh-keygen -lf $tmp) rm $tmp ((i=i+1)) echo "${username}.keys:${i} ${res/ $tmp/}" done } Invoke as: check_github_keys <username> I'm sure there's a better way to write that one though!
- bobbyi_settv 11y agoYour initial "find" version would be better if it used print0 because it would avoid failing on files with spaces in their names: find ~/.ssh -name '*.pub' -print0 | xargs -0 ssh-keygen -lf
- motoboi 11y agoThis of course can be rewritten as find ~/.ssh -name \*.pub -exec ssh-keygen -lf {} \;