fluencelabs / dev-rewards

Apache License 2.0
554 stars 368 forks source link

fix(sshkey): Remove the line break of ssh pub key #29

Closed kentio closed 4 months ago

kentio commented 4 months ago

Reprodition method: There is a line break(\n) at the end of the SSH public key, which will result in the following error.

Specified SSH key is not eligible for claiming. Only RSA and Ed25519 keys are supported for proof generation.

Use print to output the parameters in decrypt_temp_eth_account.

 def decrypt_temp_eth_account(sshPubKey, sshPrivKey, username, metadata):
+    print(sshPubKey, sshPrivKey, username, metadata.encryptedKeys[username])
     if sshPubKey not in metadata.encryptedKeys[username]:
         error("Specified SSH key is not eligible for claiming. Only RSA and Ed25519 keys are supported for proof generation.")
     data = metadata.encryptedKeys[username][sshPubKey]
     result = subprocess.run(["age",
                             "--decrypt",
                             "--identity",
                             sshPrivKey],
                            capture_output=True,
                            input=data.encode(),
                            env=env)
     if result.returncode != 0:
         raise OSError(result.stderr)
     return w3.eth.account.from_key(result.stdout.decode())

Debugging screenshot:

image image
akim-bow commented 4 months ago

Nice, thanks!