Skip to content

Instantly share code, notes, and snippets.

@rotanid
Created February 6, 2018 04:14
Show Gist options
  • Save rotanid/d7016f9ad6f41007230d4e43eda66bc0 to your computer and use it in GitHub Desktop.
Save rotanid/d7016f9ad6f41007230d4e43eda66bc0 to your computer and use it in GitHub Desktop.
sshd key length checking
# check authorized keys
while read line; do if [ "$(echo $line | wc -c)" -gt 20 ]; then echo $line > /tmp/key; ssh-keygen -l -f /tmp/key; else continue; fi; done < .ssh/authorized_keys ; rm /tmp/key >/dev/null
# check local keys
for i in .ssh/*.pub; do ssh-keygen -l -f $i; done
# check sshd host keys
for i in /etc/ssh/*.pub; do ssh-keygen -l -f $i; done
# generate new rsa host key
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa -b 4096
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment