I am trying to open an SSH client session from my Android application. Trying to connect to a device on a local network (Raspberry Pi). I am using SSHJ library version 0.10.0. It does not work when calling ssh.connect() with TransportException , which is ultimately NoSuchAlgorithmException by NoSuchAlgorithmException . See Exception Tree below.
SSHClient ssh = new SSHClient(new AndroidConfig()); Session session = null; try { //ssh.loadKnownHosts(); // Exception thrown on this line ssh.connect("192.168.1.109", 22); // Doesn't reach below ssh.authPassword("user", "password"); session = ssh.startSession(); } catch (net.schmizz.sshj.transport.TransportException ex) { ; }
Exception Tree:
net.schmizz.sshj.transport.TransportException net.schmizz.sshj.common.SSHException net.schmizz.sshj.common.SSHRuntimeException java.security.GeneralSecurityException: java.security.NoSuchAlgorithmException: KeyFactory ECDSA implementation not found java.security.NoSuchAlgorithmException: KeyFactory ECDSA implementation not found
Other system information:
SSHJ library : v0.10.0 Android device : Galaxy Note 3 running Android 4.4.2
I used maven dependency support in Android Studio to enable the SSHJ JAR, and it pulled into the following three libraries in addition to the SSHJ v0.10.0 jar ...
bouncy castle... bcpkix-jdk15on-1.50.jar bcprov-jdk15on-1.50.jar logging.... slf4j-api-1.7.7.jar
I don't know where to start this exception ... any suggestions are appreciated! Thanks.
UPDATE: 31-Oct-2014
As suggested by LeeDavidPainter , I included the SpongyCastle 1.51.0 JAR and added this line at the top:
Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
Now I get another exception on one line:
net.schmizz.sshj.transport.TransportException net.schmizz.sshj.common.SSHException net.schmizz.sshj.common.SSHRuntimeException java.security.GeneralSecurityException: java.security.spec.InvalidKeySpecException: key spec not recognised java.security.spec.InvalidKeySpecException: key spec not recognised
Also note that I tried the following line, with the same result:
Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
I have another application on my phone that basically does exactly what I want to achieve - its called RaspberryPiController - it connects to your RPi via SSH with username and password auth. This works great, so it seems like this is not a network issue.