BASH   50

ssh fingerprint server bbd sh

Guest on 17th June 2022 01:18:38 AM

  1. #!/bin/bash
  2.  
  3. # Original from:
  4. # https://superuser.com/questions/929566/sha256-ssh-fingerprint-given-by-the-client-but-only-md5-fingerprint-known-for-sex
  5. #
  6. # Modified by Edmund Laugasson
  7. #
  8. # Run current script:
  9. # source script.sh
  10.  
  11. # Set US English as default language for current script
  12. LC_ALL=C
  13.  
  14. # standard sshd config path
  15. SSHD_CONFIG=/etc/ssh/sshd_config
  16.  
  17. # helper functions
  18. function tablize {
  19.         awk '{printf("| %-7s | %-66s |\n", $1, $3)}'
  20. }
  21. LINE="+---------+--------------------------------------------------------------------+"
  22.  
  23. # header
  24. echo $LINE
  25. echo "Cipher" "Fingerprint" "Fingerprint" | tablize
  26. echo $LINE
  27.  
  28. # fingerprints
  29. for host_key in $(awk '/^HostKey/ {sub(/^HostKey\s+/,"");print $0".pub"};' $SSHD_CONFIG); do
  30.         cipher=$(echo $host_key | sed -r 's/^.*ssh_host_([^_]+)_key\.pub$/\1/'| tr '[a-z]' '[A-Z]')
  31.         if [[ -f "$host_key" ]]; then
  32.                 md5=$(ssh-keygen -l -f $host_key -E md5 | awk '{print $2}')
  33.                 sha256=$(ssh-keygen -l -f $host_key | awk '{print $2}')
  34.                 bbd=$(ssh-keygen -B -f $host_key | awk '{print $2}')
  35.  
  36.                 echo $cipher MD5 $md5 | tablize
  37.                 echo $cipher SHA256 $sha256 | tablize
  38.                 echo $cipher BBD $bbd | tablize
  39.                 echo $LINE
  40.         fi
  41. done
  42.  
  43. # BBD - easy to memorize bubblebabble digest
  44. # man ssh-keygen and search bubblebabble

Raw Paste


Login or Register to edit or fork this paste. It's free.