Diff von SSH-Keys (priv. und pub) mit Bash-Onliner

L I V E Stammtisch ab 20:30 Uhr im Chat
  • hallo und guten Morgen


    gibt es ein putty-keygen - tool in linux?

    Hintergrund: ich will gerne Keys vergleichen - das allerdings klappt mit den Methoden die ich unten zitiere nicht 100 %.

    How to check if an RSA public / private key pair match

    https://serverfault.com/questions/4263…-key-pair-match

    I have two files, id_rsa and id_rsa.pub. What command can be used to validate if they are a valid pair?

    would prefer the ssh-keygen -y -e -f <private key> way instead of the accepted answer of How do you test a public/private DSA keypair? on Stack Overflow.

    ssh-keygen -y -e -f <private key> takes a private key and prints the corresponding public key which can be directly compared to your available public keys. (Hint: beware of comments or key-options.) (How the hell is it doing that? I can only hope the public key is encoded directly or indirectly in the private key...)

    I needed this myself and used the following Bash one-liner.

    It should output nothing if the keys belong together.

    Apply a little -q to the diff in scripts and diff only sets the return code appropriately.

    PRIVKEY=id_rsa

    TESTKEY=id_rsa.pub

    Code
    diff <( ssh-keygen -y -e -f "$PRIVKEY" ) <( ssh-keygen -y -e -f "$TESTKEY" )

    der Bash onleliner liefert bei mir ein leeres ergebnis.

  • Diff von SSH-Keys (priv. und pub) mit Bash-Onliner? Schau mal ob du hier fündig wirst!

  • der Bash onleliner liefert bei mir ein leeres ergebnis.

    Wenn die zwei Files identisch sind.... was müsste er denn dann liefern? Hast Du mal den Rückgabewert überprüft? Ist der nämlich 0, sind die beiden identisch und es erfolgt keine Ausgabe. Ist er 1 sind sie unterschiedlich. Bei 1 müssten aber auch die Unterschiede angezeigt werden.

  • hallo ThomasL

    vielen Dank für Deine rasche Antwort - du hast Recht - ich hab das letzte Nacht ausprobiert und mich noch gewundert. ABER sicher - ich denke dass du da absoult Recht hast.

    Wenn er nichts liefert - dann sind die Keys passend - und dann ist alles okay.

    Dir vielen Dank!!!

    Wenn die zwei Files identisch sind.... was müsste er denn dann liefern? Hast Du mal den Rückgabewert überprüft? Ist der nämlich 0, sind die beiden identisch und es erfolgt keine Ausgabe. Ist er 1 sind sie unterschiedlich. Bei 1 müssten aber auch die Unterschiede angezeigt werden.

    viele Grüße

Jetzt mitmachen!

Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!