"no such algorithm: ECDSA for provider BC" when connect(host, port) from Android app
- Dominant language
- Java
- Stars
- 2.7k
- Forks
- 620
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 11
Description
I was able to use the sshj lib to connect, authenticate, and execute remote commands from a standalone Kotlin client (command line).
But then when I tried to use the lib from a simple Android app it failed to even connect to the same server I used before from command line app.
I get `net.schmizz.sshj.transport.TransportException: no such algorithm: ECDSA for provider BC` (please see below the full error stack #1 from logcat):
The code is very simple:
```
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
CoroutineScope(Dispatchers.IO).launch{
val ssh = SSHClient()
ssh.addHostKeyVerifier(PromiscuousVerifier()) // it makes no difference
ssh.connect("www.blabla.com", 22223) <== it throws exception even before authenticating
//ssh.authPublickey(username, kp)
}
}
}
```
I've tried to add the following dependencies, but nothing really helped:
```
dependencies {
//...
implementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
implementation 'com.hierynomus:sshj:0.34.0'
```
Any idea what I'm doing wrong?
Also I'm new to Android + Java + Kotlin dev, I see in "Project Structure..." I do have 6 x ways to add `sshj`:

What do they mean?
Are they all valid options?
Why in my error stack #1 I see `net.schmizz.sshj*`, even I'm actually using `com.hierynomus:ssh*`?!
[...]
BTW I've tried to replace com.hierynomus:ssh => net.schmizz.sshj, only to get another fatal exception:
`net.schmizz.sshj.transport.TransportException: Unable to reach a settlement: [diffie-hellman-group14-sha1, diffie-hellman-group1-sha1] and [curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256]`
(also see full error stack below)
Thanks for help,
Petru
STACK #1
======
```
2022-11-28 17:38:09.261 10147-10179 AndroidRuntime com.example.sshjdemo E FATAL EXCEPTION: DefaultDispatcher-worker-2
Process: com.example.sshjdemo, PID: 10147
net.schmizz.sshj.transport.TransportException: no such algorithm: ECDSA for provider BC
at net.schmizz.sshj.transport.TransportException$1.chain(TransportException.java:33)
at net.schmizz.sshj.transport.TransportException$1.chain(TransportException.java:27)
at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
at net.schmizz.concurrent.Event.deliverError(Event.java:74)
at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(ErrorDeliveryUtil.java:34)
at net.schmizz.sshj.transport.KeyExchanger.notifyError(KeyExchanger.java:416)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:587)
at net.schmizz.sshj.transport.Reader.run(Reader.java:66)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@10156fe, Dispatchers.IO]
Caused by: net.schmizz.sshj.common.SSHException: no such algorithm: ECDSA for provider BC
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:37)
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:30)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:582)
... 1 more
Caused by: net.schmizz.sshj.common.SSHRuntimeException: no such algorithm: ECDSA for provider BC
at net.schmizz.sshj.transport.kex.DHBase.(DHBase.java:41)
at net.schmizz.sshj.transport.kex.Curve25519DH.(Curve25519DH.java:35)
at net.schmizz.sshj.transport.kex.Curve25519SHA256.(Curve25519SHA256.java:54)
at net.schmizz.sshj.transport.kex.Curve25519SHA256$Factory.create(Curve25519SHA256.java:44)
at net.schmizz.sshj.transport.kex.Curve25519SHA256$Factory.create(Curve25519SHA256.java:39)
at net.schmizz.sshj.common.Factory$Named$Util.create(Factory.java:54)
at net.schmizz.sshj.transport.KeyExchanger.gotKexInit(KeyExchanger.java:242)
at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:380)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:485)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:113)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:200)
at net.schmizz.sshj.transport.Reader.run(Reader.java:60)
Caused by: java.security.NoSuchAlgorithmException: no such algorithm: ECDSA for provider BC
at sun.security.jca.GetInstance.getService(GetInstance.java:87)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:206)
at java.security.KeyPairGenerator.getInstance(KeyPairGenerator.java:319)
at net.schmizz.sshj.common.SecurityUtils.getKeyPairGenerator(SecurityUtils.java:188)
at net.schmizz.sshj.transport.kex.DHBase.(DHBase.java:38)
at net.schmizz.sshj.transport.kex.Curve25519DH.(Curve25519DH.java:35)
at net.schmizz.sshj.transport.kex.Curve25519SHA256.(Curve25519SHA256.java:54)
at net.schmizz.sshj.transport.kex.Curve25519SHA256$Factory.create(Curve25519SHA256.java:44)
at net.schmizz.sshj.transport.kex.Curve25519SHA256$Factory.create(Curve25519SHA256.java:39)
at net.schmizz.sshj.common.Factory$Named$Util.create(Factory.java:54)
at net.schmizz.sshj.transport.KeyExchanger.gotKexInit(KeyExchanger.java:242)
at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:380)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:485)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:113)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:200)
at net.schmizz.sshj.transport.Reader.run(Reader.java:60)
2022-11-28 17:38:09.411 10147-10179 Process com.example.sshjdemo I Sending signal. PID: 10147 SIG: 9
---------------------------- PROCESS ENDED (10147) for package com.example.sshjdemo ----------------------------
```
STACK #2
=======
```
2022-11-28 17:57:54.376 10506-10561 AndroidRuntime com.example.sshjdemo E FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: com.example.sshjdemo, PID: 10506
net.schmizz.sshj.transport.TransportException: Unable to reach a settlement: [diffie-hellman-group14-sha1, diffie-hellman-group1-sha1] and [curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256]
at net.schmizz.sshj.transport.Proposal.firstMatch(Proposal.java:145)
at net.schmizz.sshj.transport.Proposal.negotiate(Proposal.java:128)
at net.schmizz.sshj.transport.KeyExchanger.gotKexInit(KeyExchanger.java:219)
at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:344)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:458)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:107)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:175)
at net.schmizz.sshj.transport.Reader.run(Reader.java:61)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@b10e967, Dispatchers.IO]
2022-11-28 17:57:54.498 10506-10561 Process com.example.sshjdemo I Sending signal. PID: 10506 SIG: 9
---------------------------- PROCESS ENDED (10506) for package com.example.sshjdemo ----------------------------
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.