Holen Sie sich den Fingerabdruck eines vorhandenen öffentlichen SSH-Schlüssels

Diese Frage fragt nach dem Abrufen des - Fingerabdrucks eines SSH-Schlüssels beim Generieren des neuen Schlüssels mit ssh-keygen.

Aber wie ermittelt man den Fingerabdruck eines vorhandenen öffentlichen Schlüssels in einer .pub Datei?

➥ Wie bekomme ich:

  • SHA256-hash eines vorhandenen Schlüssels?
    So etwas wie dieses: SHA256:3VvabBNtRF0XEpYRFnIrhHX6tKZq/vzU+heb3dCYp+0 [email protected]
  • MD5 (ist es MD5?) eines vorhandenen Schlüssels?
    So etwas wie dieses: b6:bf:18:b8:72:83:b7:fb:7d:08:98:72:1f:9f:05:27
  • Randomart für einen vorhandenen Schlüssel?
    So etwas wie dieses:
+--[ RSA 2048]----+
|       o=.       |
|    o  o++E      |
|   + . Ooo.      |
|    + O B..      |
|     = *S.       |
|      o          |
|                 |
|                 |
|                 |
+-----------------+
Author: Basil Bourque, 2018-11-20

3 answers

In neueren Versionen von ssh-keygen erhält man einen öffentlichen RSA-Schlüssel. auf Unix-basierten Systemen mit etwas wie:

$ ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub

Wobei der Pfad auf eine öffentliche Schlüsseldatei verweist.

 11
Author: Cris P,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2019-04-16 04:33:20

Installation openssh - und openssl - - Pakete, die enthalten die Befehle.

# get the SHA256 and ascii art    
ssh-keygen -l -v -f /path/to/publickey

# get the MD5 for private key
openssl pkey -in /path/to/privatekey -pubout -outform DER | openssl md5 -c

# get the MD5 for public key
openssl pkey -in /path/to/publickey -pubin -pubout -outform DER | openssl md5 -c
 7
Author: strobelight,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2018-11-28 03:50:53

Das Obige funktioniert, wenn Sie Zugriff auf den Remote-Host haben. Wenn nicht, können Sie dies tun, um die Standard-sha256-Hashes und-Werte vom Remote-Host 'pi' abzurufen (z. B.):

$ ssh-keyscan pi | ssh-keygen -lvf -
# pi:22 SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u4
# pi:22 SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u4
# pi:22 SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u4
2048 SHA256:P/Da4p1YbLDgnbGIkVE9SykONlVynPkwwap54RMW6+A pi (RSA)
+---[RSA 2048]----+
|     .+=+=       |
|    +.oo%        |
|   ..+ * *       |
|    .oB . .      |
|   .oB.oS        |
|    E+=+ @       |
|    ..o.= B      |
|        .B o     |
|       .+.+      |
+----[SHA256]-----+
256 SHA256:eMaAlpPMA2/24ajrpHuiL7mCFCJycZNfuNfyB3cyx+U pi (ECDSA)
+---[ECDSA 256]---+
|  .  . .         |
|  .=++. .       .|
|   o&ooo .   . o |
|+..+ *o=o o + + E|
|+.. . +.So o =   |
| . .   o  . .    |
|o.o        .     |
|*o..             |
|BO+              |
+----[SHA256]-----+
256 SHA256:cpQtotFCbt4TXxa1474whR1Wkk3gOczhumE23s9pbxc pi (ED25519)
+--[ED25519 256]--+
|    .     ..==o  |
|   o .   o *.*.  |
|    = + + + %    |
|   o = = + * +   |
|    o + S B +    |
|       + + B   E |
|          = o   .|
|           o +..o|
|            ..+oo|
+----[SHA256]-----+
$ _

Wenn Sie stattdessen den MD5-Hash möchten:

$ ssh-keyscan pi | ssh-keygen -E md5 -lf -
# pi:22 SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u4
# pi:22 SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u4
# pi:22 SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u4
256 MD5:b3:74:1f:a7:e8:96:ee:e0:5d:7e:31:4d:5c:7c:5c:d2 pi (ECDSA)
2048 MD5:cb:1f:5b:85:fb:6f:c9:89:06:68:ce:96:88:f6:11:ed pi (RSA)
256 MD5:d7:93:a1:8e:53:06:4d:fe:41:5c:fa:4b:70:84:c3:88 pi (ED25519)
$ _

Wenn Sie sich auf dem tatsächlichen Host befinden und diese abrufen möchten, sudo Sie einfach den Teil nach der Pipe wie folgt:

$ sudo ssh-keygen -E sha256 -lf /etc/ssh/ssh_host_ecdsa_key
256 SHA256:eMaAlpPMA2/24ajrpHuiL7mCFCJycZNfuNfyB3cyx+U root@raspberrypi (ECDSA)
$ _

Und sha256 ist der Standard, also würden Sie ' md5 ' verwenden, um das zu bekommen.

Hoffe, das hilft.

Patrick

 5
Author: patrick,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2019-01-06 04:19:53