-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is an error while parsing ed25519 key generated by SSH Key generator #743
Comments
Hi @bade7n, If it's missing the public key part as you've indicated, then that would indicate to me that it is not encoded correctly, and that you should instead by contacting the vendor that generated that key. Thanks, |
An interesting part here is that 0.1.x versions work well as just ignores exception in 0.1.72: KeyPair.java:929 (ArrayIndexOutOfBoundsException while eval |
I'm not sure why you are opening an issue with us: the key you provided is clearly invalid: why are you not taking up the issue with the vendor who's tool generated an invalid key in the first place? |
@norrisjeremy we shared that understanding but in theory public part is not required in case of DeferredKey so maybe there is some logic underneath as openssh works well with it. |
As I understand unencrypted public part might be missing by purpose to hide the key identity and its basically not needed as that information is duplicated in encrypted private part. |
Instead of guessing, could you perhaps instead contact the vendor who's tools generated this key in the first place? |
Hi @bade7n, Additionally, I'm not even able reproduce the reported exception, using the following test case: import com.jcraft.jsch.JSch;
import com.jcraft.jsch.KeyPair;
import java.util.Arrays;
public class Foo {
public static void main(String[] args) throws Exception {
var key = """
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABBU
PQlHJLBkOF1EzB92Z54rAAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIKxn
01gBk+MroNLf5TjynfuaoZLmI/mdztWpL01ySIOEAAAAkEtCYMx9c01TYzW97I3t
UjRAskPMCptf7L75bUf/HmxvUni/Ht5skcI9WGK78sE8moYZT/g+9bm8X2P6bcLS
sVY/a86JdXmvoio8I6lz8Wm7JZIhtbu7RHItYUyOkBVAPkfaEmooeNxQMaQdw96S
1b+wSOP4N/JvD3FbD5TBxBYIwMViMaccbZ5/dj2OMd2XmA==
-----END OPENSSH PRIVATE KEY-----
""";
var kp = KeyPair.load(new JSch(), key.getBytes("UTF-8"), null);
System.out.println(kp.getKeyTypeString());
System.out.println(Arrays.toString(kp.getPublicKeyBlob()));
System.out.println(kp.getFingerPrint());
System.out.println(kp.isEncrypted());
}
} With the above test case, I see the following output and no exceptions thrown:
Is there something I'm missing? Thanks, |
yes, wrong key attached, my bad, I've checked too many keys yesterday
|
Hi @bade7n, Whilst I am now able to reproduce the reported exception using the new key you provided, I am not keen on adding a workaround to JSch. Additionally, nothing that I see in the OpenSSH documentation of the key format seems to indicate that the publickey field(s) are optional and can be omitted. So I would be inclined to push back on the vendor that is producing keys in this format to better understand why they are doing this and if they can instead fix the problem on their end. Thanks, |
Completely agree on that. I've contacted devolutions but it might take a while. |
Hi @bade7n, Have you also confirmed that OpenSSH itself can handle the provided SSH key correctly? Thanks, |
it could be converted via puttygen back to proper openssh format. |
Hi @bade7n, Do you happen to know the passphrase to decrypt this key? Thanks, |
Passphrase: R2rfgX24Lun9rhGarfjPrVkcdj4DA4 |
Hi @bade7n, My initial testing of this key indicates that not even OpenSSH itself can handle it.
Since OpenSSH itself seems unable to handle it, I am especially disinclined to add a workaround for it to JSch. Thanks, |
jsch version v 0.2.18
error while trying to import encrypted ed25519 key generated by https://docs.devolutions.net/rdm/commands/tools/ssh-key/ SSH key generator.
The key is missing public part
Initiated by our customer here.
The text was updated successfully, but these errors were encountered: