Last active
August 12, 2020 23:37
-
-
Save xeoncross/5326443 to your computer and use it in GitHub Desktop.
Generate a fingerprint from and RSA SSH public key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
print "\n"; | |
$rsa = file_get_contents('rsa.pub'); | |
$ssh = file_get_contents('ssh.pub'); | |
// For reference | |
print $rsa . "\n\n"; | |
print $ssh . "\n\n"; | |
print exec('ssh-keygen -lf ssh.pub') . "\n\n"; // What should be correct | |
// Get the middle part out, decode it, and hash it | |
$content = explode(' ', $ssh, 3); | |
print join(':', str_split(md5(base64_decode($content[1])), 2)) . "\n\n"; | |
/* Output: | |
-----BEGIN PUBLIC KEY----- | |
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbIEIZZ1TOwy4eJyk5XK5chARj | |
nGJnfvJUbDBrDuyYqPsAgX/uoHWV/T8XN80cwpTcLalfS2lYsBrEy75w4o2vfto6 | |
VCIFKG2w5anABC0BVB52DBUGXp1x1gGU4RZ3VNdQAmeMaJijzoCpkRb6+uD9pw2w | |
rlnmSiNINdBXYmC2fwIDAQAB | |
-----END PUBLIC KEY----- | |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCbIEIZZ1TOwy4eJyk5XK5chARjnGJnfvJUbDBrDuyYqPsAgX/uoHWV/T8XN80cwpTcLalfS2lYsBrEy75w4o2vfto6VCIFKG2w5anABC0BVB52DBUGXp1x1gGU4RZ3VNdQAmeMaJijzoCpkRb6+uD9pw2wrlnmSiNINdBXYmC2fw== phpseclib-generated-key | |
1024 27:0a:59:be:74:ff:6d:11:0a:9a:b6:cf:fe:fd:dc:d1 phpseclib-generated-key (RSA) | |
27:0a:59:be:74:ff:6d:11:0a:9a:b6:cf:fe:fd:dc:d1 | |
^ WIN! | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCbIEIZZ1TOwy4eJyk5XK5chARjnGJnfvJUbDBrDuyYqPsAgX/uoHWV/T8XN80cwpTcLalfS2lYsBrEy75w4o2vfto6VCIFKG2w5anABC0BVB52DBUGXp1x1gGU4RZ3VNdQAmeMaJijzoCpkRb6+uD9pw2wrlnmSiNINdBXYmC2fw== phpseclib-generated-key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i'd like to know how i could complie this code, can i use the Cmd of windows.
Please could u write me down the command line.
Thanks