Erik Wasser
2016-11-04 21:20:03 UTC
Summary: Is there a known problem with SSH and RSA keys with 4096 bits?
Recently I noticed that using the SFTP plugin of my favorite editor
jedit wasn't working anymore. To make a long story short: I've drilled
down the problem to the library JSch (jsch-0.1.54.jar) and compiled one
of your example:
I'm using UserAuthPubKey.java
(http://www.jcraft.com/jsch/examples/UserAuthPubKey.java.html) example
with a 2 different keys:
% ssh-keygen -lf ~/.ssh/id_rsa-2048
2048 SHA256:e8G+h4MsuUMZYUbk2jhk18FGQ88JNB/Lpxzpw/kfAeY
***@namm.de (RSA)
% ssh-keygen -lf ~/.ssh/id_rsa-4096
4096 SHA256:3M4Mx6KUodWqWfdVWOr0cavdapf8y+zIH3bXcl7umbo
***@namm.de (RSA)
The first one is working fine, that last one returns the following message
throwing from the code snippet
JSchException. Here's the relevant part:
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose "+
chooser.getSelectedFile().getAbsolutePath()+".");
System.out.println("before jsch.addIdentity()");
jsch.addIdentity(chooser.getSelectedFile().getAbsolutePath());
System.out.println("after jsch.addIdentity()");
}
Compiling (using the oracle JDK 1.8.0_101):
% javac -classpath jsch.jar UserAuthPubKey.java
Starting and using the 2048 bit key:
% java -classpath jsch.jar:. UserAuthPubKey
You chose /home/brassel/.ssh/id_rsa-2048.
before jsch.addIdentity()
after jsch.addIdentity()
...Program goes on...
Starting and using the 4096 bit key:
% java -classpath jsch.jar:. UserAuthPubKey
You chose /home/brassel/.ssh/id_rsa-4096.
before jsch.addIdentity()
com.jcraft.jsch.JSchException: invalid privatekey: [***@48140564
...Program ends here...
Why is that? Why are 4096 bits RSA keys invalid? How can I fix this issue?
Recently I noticed that using the SFTP plugin of my favorite editor
jedit wasn't working anymore. To make a long story short: I've drilled
down the problem to the library JSch (jsch-0.1.54.jar) and compiled one
of your example:
I'm using UserAuthPubKey.java
(http://www.jcraft.com/jsch/examples/UserAuthPubKey.java.html) example
with a 2 different keys:
% ssh-keygen -lf ~/.ssh/id_rsa-2048
2048 SHA256:e8G+h4MsuUMZYUbk2jhk18FGQ88JNB/Lpxzpw/kfAeY
***@namm.de (RSA)
% ssh-keygen -lf ~/.ssh/id_rsa-4096
4096 SHA256:3M4Mx6KUodWqWfdVWOr0cavdapf8y+zIH3bXcl7umbo
***@namm.de (RSA)
The first one is working fine, that last one returns the following message
throwing from the code snippet
jsch.addIdentity(chooser.getSelectedFile().getAbsolutePath());
If've modified UserAuthPubKey.java a little bit to drill down theJSchException. Here's the relevant part:
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose "+
chooser.getSelectedFile().getAbsolutePath()+".");
System.out.println("before jsch.addIdentity()");
jsch.addIdentity(chooser.getSelectedFile().getAbsolutePath());
System.out.println("after jsch.addIdentity()");
}
Compiling (using the oracle JDK 1.8.0_101):
% javac -classpath jsch.jar UserAuthPubKey.java
Starting and using the 2048 bit key:
% java -classpath jsch.jar:. UserAuthPubKey
You chose /home/brassel/.ssh/id_rsa-2048.
before jsch.addIdentity()
after jsch.addIdentity()
...Program goes on...
Starting and using the 4096 bit key:
% java -classpath jsch.jar:. UserAuthPubKey
You chose /home/brassel/.ssh/id_rsa-4096.
before jsch.addIdentity()
com.jcraft.jsch.JSchException: invalid privatekey: [***@48140564
...Program ends here...
Why is that? Why are 4096 bits RSA keys invalid? How can I fix this issue?
--
So long... Erik
So long... Erik