Open alperenp opened 5 years ago
Can you send the debug logging of the full connection/login attempt?
Sure, I anonymized fingerprint, ip address and some class names.
INFO: Connecting now Wed Jul 17 13:20:58 CEST 2019
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2019-07-17 method name
WARNING: HOST_KEY_NOT_VERIFIABLE: trusting fingerprint xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx: net.schmizz.sshj.transport.TransportException: Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `ip-addr` on port 22
at net.schmizz.sshj.transport.KeyExchanger.verifyHost(KeyExchanger.java:211)
at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:365)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:503)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
2019-07-17 13:21:02 [Connection Manager Thread] utils.ssh.Session.create()
DEBUG: Authentication failed: net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:230)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:345)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:363)
...
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:117)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:38)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: net.schmizz.sshj.userauth.UserAuthException
at net.schmizz.sshj.userauth.UserAuthException$1.chain(UserAuthException.java:33)
at net.schmizz.sshj.userauth.UserAuthException$1.chain(UserAuthException.java:26)
at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
at net.schmizz.sshj.userauth.UserAuthImpl.notifyError(UserAuthImpl.java:156)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:601)
at net.schmizz.sshj.transport.Reader.run(Reader.java:65)
Caused by: net.schmizz.sshj.common.SSHException
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:36)
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:29)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:595)
at net.schmizz.sshj.transport.Reader.run(Reader.java:65)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at net.schmizz.sshj.signature.SignatureECDSA.encode(SignatureECDSA.java:96)
at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putSig(KeyedAuthMethod.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.sendSignedReq(AuthPublickey.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.handle(AuthPublickey.java:45)
at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:142)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
2019-07-17 13:21:02 [Connection Manager Thread] utils.ssh.Session.create()
DEBUG: Due to some error, the SSH tunnel creation did not work, force close
Stacktrace:
|_/ SSH Tunnel error: authentication failed: Exhausted available authentication methods
|____/ SSH Tunnel error: Exhausted available authentication methods
|_______/ SSH Tunnel error: null
|__________/ SSH Tunnel error: null
|_____________/ Index out of bounds: null: utils.connman.ConnectionManagerException: SSH Tunnel error: authentication failed: Exhausted available authentication methods
Stacktrace:
|_/ SSH Tunnel error: authentication failed: Exhausted available authentication methods
|____/ SSH Tunnel error: Exhausted available authentication methods
|_______/ SSH Tunnel error: null
|__________/ SSH Tunnel error: null
|_____________/ Index out of bounds: null
...
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:117)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:38)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: utils.ssh.SshException: authentication failed: Exhausted available authentication methods
...
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:117)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:38)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:230)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:345)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:363)
...
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:117)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:38)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77)
...
If necessary, I can provide code itself as a separate project
Can you add a slf4j logger implementation and ensure that there is debug level logging? Currently no logger is configured (noop).
Op wo 17 jul. 2019 15:11 schreef alperenp notifications@github.com:
If necessary, I can provide code itself as a separate project
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hierynomus/sshj/issues/521?email_source=notifications&email_token=AAA4XI3WTTOLJCBJBSBFJWDP74K7VA5CNFSM4IEOHDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2EEOCQ#issuecomment-512247562, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA4XI3TPKT6ADPLWW4AL4LP74K7VANCNFSM4IEOHDWA .
Here is code
import net.schmizz.sshj.Config;
import net.schmizz.sshj.DefaultConfig;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.common.DisconnectReason;
import net.schmizz.sshj.transport.TransportException;
import net.schmizz.sshj.userauth.UserAuthException;
import net.schmizz.sshj.userauth.keyprovider.KeyProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.net.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by alperenp on 2019-07-10.
*/
public class Test {
private static final Logger logger = LoggerFactory.getLogger(Test.class);
private static SSHClient createConnectedSSHClient(
Proxy proxy,
boolean isLoadKnownHosts,
boolean isFailOnHostKeyNotVerifiable,
String... trustedFingerprints
) throws IOException {
Config config = new DefaultConfig();
SSHClient sshClient = new SSHClient(config);
if (isLoadKnownHosts) {
try {
sshClient.loadKnownHosts();
}
catch (IOException ignored) {
}
}
sshClient.setTimeout(30000);
sshClient.setConnectTimeout(30000);
// prepare the SSH session
try {
for (String fingerprint : trustedFingerprints) {
sshClient.addHostKeyVerifier(fingerprint);
}
sshClient.connect("ip-addr-here", 22, proxy);
}
catch (TransportException ex) {
if (ex.getDisconnectReason() == DisconnectReason.HOST_KEY_NOT_VERIFIABLE) {
if (isFailOnHostKeyNotVerifiable) {
throw ex;
}
final Pattern fingerprintPattern = Pattern.compile(
".*?(?<fingerprint>[a-fA-F0-9]{2}(:[a-fA-F0-9]{2})+).*?"
);
// Extract the fingerprint from the error message
Matcher matcher = fingerprintPattern.matcher(ex.getMessage());
String fingerprint = matcher.find() ? matcher.group("fingerprint") : "";
List<String> fingerPrintList = new ArrayList<>(Arrays.asList(trustedFingerprints));
fingerPrintList.add(fingerprint);
return createConnectedSSHClient(
proxy, isLoadKnownHosts,
true, // this is important to be 'true' to avoid infinite recursion
fingerPrintList.toArray(new String[fingerPrintList.size()])
);
}
throw ex;
}
return sshClient;
}
private static void create() throws Exception {
SSHClient sshClient;
try {
sshClient = createConnectedSSHClient(Proxy.NO_PROXY, true, false);
File privateKey = new File("path/to/ecdsa/key");
KeyProvider keyProvider = sshClient.loadKeys(
privateKey.getAbsolutePath(),
"ecdsa passphrase here".toCharArray()
);
keyProvider.getPrivate();
sshClient.authPublickey("username here", keyProvider);
}
catch (UserAuthException userAuthException) {
logger.debug("Failure!", userAuthException);
throw new UserAuthException("authentication failed: " + userAuthException.getMessage(), userAuthException);
}
catch (Exception ex) {
throw ex;
}
}
public static void main(String[] args) throws Exception {
//Security.addProvider(new BouncyCastleProvider());
create();
}
}
Here is log
Connected to the target VM, address: '127.0.0.1:55015', transport: 'socket'
17:04:49.630 [main] INFO net.schmizz.sshj.transport.random.BouncyCastleRandom - Generating random seed from SecureRandom.
17:04:49.632 [main] DEBUG net.schmizz.sshj.transport.random.BouncyCastleRandom - Creating random seed took 0 ms
17:04:49.681 [main] DEBUG net.schmizz.sshj.DefaultConfig - Available cipher factories: [aes128-cbc, aes128-ctr, aes192-cbc, aes192-ctr, aes256-cbc, aes256-ctr, blowfish-cbc, blowfish-ctr, cast128-cbc, cast128-ctr, idea-cbc, idea-ctr, serpent128-cbc, serpent128-ctr, serpent192-cbc, serpent192-ctr, serpent256-cbc, serpent256-ctr, 3des-cbc, 3des-ctr, twofish128-cbc, twofish128-ctr, twofish192-cbc, twofish192-ctr, twofish256-cbc, twofish256-ctr, twofish-cbc, arcfour, arcfour128, arcfour256]
17:04:49.707 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [61, 22, 17, -6, -121, -45, -123, 23, -35, 54, -118, 22, -59, 86, -26, -62, 110, -14, -39, 89, 106, -5, 95, -53, 103, -86, 114, 95, 50, 27, -52, -23]
y: [3, -56, -84, 113, -54, -96, 84, 49, -98, -29, 94, -99, 39, 62, -40, -118, -56, 66, 123, -71, 102, -49, 34, -31, 1, 22, -79, 86, -125, -84, 35, -87]
17:04:49.811 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [-94, 95, -57, -96, 126, -116, -78, -113, -33, 116, -26, -19, -8, 95, -14, -126, -68, -76, -43, -105, -87, -114, 118, 115, -92, -91, -44, -18, 8, 11, -104, -23]
y: [103, 122, 114, 82, 60, -1, -110, -53, -97, -2, 10, 19, -94, -96, -87, -113, 32, -79, 21, 89, 64, -85, -44, -78, -14, 40, -110, -18, 124, 77, 37, -43]
17:04:49.812 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [20, 43, -124, -81, 51, -13, 50, 126, 58, 17, 18, 107, -75, -102, 76, -83, 64, -120, 43, -36, 42, 4, 39, 62, 66, 82, 83, 109, -35, 47, -44, 94]
y: [-75, -51, -107, -14, 90, -113, -17, -126, 53, -89, -46, 119, -92, -89, 71, 85, -49, -101, -31, -125, 71, -81, 14, -94, 0, 38, -27, 51, -88, -19, 74, 30]
17:04:49.812 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [66, -71, -48, 41, 27, 59, 6, 109, 113, 1, 2, 119, -96, -60, -127, 1, 46, -124, 100, -105, 13, -61, 84, 102, 13, 116, -89, -62, 116, 5, -22, -55]
y: [-36, -98, 76, -107, -94, 104, 126, 94, -17, 100, 113, 113, 5, 0, -69, 104, 21, 66, 53, 78, -97, 13, 0, -11, -96, 63, -35, 45, -19, -89, -97, -124]
17:04:49.813 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [13, -17, -106, 74, 79, 82, 11, -17, 85, 27, -80, -44, -14, -34, 75, -97, 69, -102, -65, -27, 92, -67, 21, -87, 56, 84, 77, 109, 14, -10, -53, -83]
y: [56, -46, -22, 56, 111, 4, 29, -68, -59, 64, 87, 50, 70, -58, -54, 19, 102, 66, -93, -87, 12, -96, -15, -43, 37, 10, -119, -6, -80, 124, 108, 10]
17:04:49.813 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [57, -96, -110, 121, -14, 23, -44, -4, -68, -49, -105, 108, -107, -4, 91, -57, -77, -71, 110, -39, 44, 5, -16, -19, 31, -101, 112, 48, 68, -25, -61, 39]
y: [60, 50, -90, 106, -59, -72, 81, -52, 11, 103, 7, -31, 94, -98, 71, 115, 64, -73, -65, -105, -98, -123, 24, 59, 59, 52, -29, 105, -57, 102, 126, 96]
17:04:49.813 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [90, -80, 108, -124, -91, -14, 48, 99, 95, 105, -73, -70, 88, 14, -79, -4, -65, -122, -47, 30, -38, -2, -101, -19, 65, -98, 19, 55, 123, 88, 91, 23]
y: [8, -78, 79, 53, 9, 96, 40, 82, -121, 76, 12, 60, 12, -113, -17, 103, 127, -121, -80, 4, -82, -101, -93, -81, 27, 17, -127, -70, 74, 20, 120, 36]
17:04:49.819 [main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.27.0
17:04:49.822 [main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
17:04:49.822 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `null`
17:04:49.822 [main] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT
17:04:49.824 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT
17:04:49.824 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `SOME`
17:04:49.824 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<kex done>>
17:04:49.825 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Negotiated algorithms: [ kex=curve25519-sha256; sig=ssh-ed25519; c2sCipher=aes128-ctr; s2cCipher=aes128-ctr; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none ]
17:04:49.843 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Sending SSH_MSG_KEXDH_INIT
17:04:49.848 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received kex followup data
17:04:49.848 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Received SSH_MSG_KEXDH_REPLY
17:04:49.848 [reader] DEBUG net.schmizz.sshj.common.KeyType - Key algo: ssh-ed25519, Key curve: 25519, Key Len: 32
p: [44, 106, 18, 44, -29, -51, 2, -46, -95, -8, -43, 56, 103, 113, 48, 17, 16, -50, 118, 96, 61, 55, -16, -77, 109, 11, 117, 38, -82, 96, -87, -52]
17:04:49.868 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts'}
17:04:49.868 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts2'}
17:04:49.869 [reader] ERROR net.schmizz.sshj.transport.KeyExchanger - Disconnecting because none of the configured Host key verifiers ([OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts'}, OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts2'}]) could verify 'ssh-ed25519' host key with fingerprint xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx for x.x.x.x:22
17:04:49.871 [reader] ERROR net.schmizz.sshj.transport.TransportImpl - Dying because - Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
net.schmizz.sshj.transport.TransportException: Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
at net.schmizz.sshj.transport.KeyExchanger.verifyHost(KeyExchanger.java:211)
at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:365)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:503)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
17:04:49.871 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - HOST_KEY_NOT_VERIFIABLE
17:04:49.871 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Got notified of net.schmizz.sshj.transport.TransportException: [HOST_KEY_NOT_VERIFIABLE] Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
17:04:49.872 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl$NullService - Notified of net.schmizz.sshj.transport.TransportException: [HOST_KEY_NOT_VERIFIABLE] Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
17:04:49.872 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to null-service
17:04:49.872 [main] ERROR net.schmizz.concurrent.Promise - <<kex done>> woke to: net.schmizz.sshj.transport.TransportException: [HOST_KEY_NOT_VERIFIABLE] Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
17:04:49.872 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_DISCONNECT: reason=[HOST_KEY_NOT_VERIFIABLE], msg=[Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22]
17:04:49.873 [main] INFO net.schmizz.sshj.transport.random.BouncyCastleRandom - Generating random seed from SecureRandom.
17:04:49.873 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to `SOME`
17:04:49.873 [reader] DEBUG net.schmizz.sshj.transport.Reader - Stopping
17:04:49.873 [main] DEBUG net.schmizz.sshj.transport.random.BouncyCastleRandom - Creating random seed took 0 ms
17:04:49.877 [main] DEBUG net.schmizz.sshj.DefaultConfig - Available cipher factories: [aes128-cbc, aes128-ctr, aes192-cbc, aes192-ctr, aes256-cbc, aes256-ctr, blowfish-cbc, blowfish-ctr, cast128-cbc, cast128-ctr, idea-cbc, idea-ctr, serpent128-cbc, serpent128-ctr, serpent192-cbc, serpent192-ctr, serpent256-cbc, serpent256-ctr, 3des-cbc, 3des-ctr, twofish128-cbc, twofish128-ctr, twofish192-cbc, twofish192-ctr, twofish256-cbc, twofish256-ctr, twofish-cbc, arcfour, arcfour128, arcfour256]
17:04:49.878 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [61, 22, 17, -6, -121, -45, -123, 23, -35, 54, -118, 22, -59, 86, -26, -62, 110, -14, -39, 89, 106, -5, 95, -53, 103, -86, 114, 95, 50, 27, -52, -23]
y: [3, -56, -84, 113, -54, -96, 84, 49, -98, -29, 94, -99, 39, 62, -40, -118, -56, 66, 123, -71, 102, -49, 34, -31, 1, 22, -79, 86, -125, -84, 35, -87]
17:04:49.878 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [-94, 95, -57, -96, 126, -116, -78, -113, -33, 116, -26, -19, -8, 95, -14, -126, -68, -76, -43, -105, -87, -114, 118, 115, -92, -91, -44, -18, 8, 11, -104, -23]
y: [103, 122, 114, 82, 60, -1, -110, -53, -97, -2, 10, 19, -94, -96, -87, -113, 32, -79, 21, 89, 64, -85, -44, -78, -14, 40, -110, -18, 124, 77, 37, -43]
17:04:49.878 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [20, 43, -124, -81, 51, -13, 50, 126, 58, 17, 18, 107, -75, -102, 76, -83, 64, -120, 43, -36, 42, 4, 39, 62, 66, 82, 83, 109, -35, 47, -44, 94]
y: [-75, -51, -107, -14, 90, -113, -17, -126, 53, -89, -46, 119, -92, -89, 71, 85, -49, -101, -31, -125, 71, -81, 14, -94, 0, 38, -27, 51, -88, -19, 74, 30]
17:04:49.879 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [66, -71, -48, 41, 27, 59, 6, 109, 113, 1, 2, 119, -96, -60, -127, 1, 46, -124, 100, -105, 13, -61, 84, 102, 13, 116, -89, -62, 116, 5, -22, -55]
y: [-36, -98, 76, -107, -94, 104, 126, 94, -17, 100, 113, 113, 5, 0, -69, 104, 21, 66, 53, 78, -97, 13, 0, -11, -96, 63, -35, 45, -19, -89, -97, -124]
17:04:49.879 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [13, -17, -106, 74, 79, 82, 11, -17, 85, 27, -80, -44, -14, -34, 75, -97, 69, -102, -65, -27, 92, -67, 21, -87, 56, 84, 77, 109, 14, -10, -53, -83]
y: [56, -46, -22, 56, 111, 4, 29, -68, -59, 64, 87, 50, 70, -58, -54, 19, 102, 66, -93, -87, 12, -96, -15, -43, 37, 10, -119, -6, -80, 124, 108, 10]
17:04:49.879 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [57, -96, -110, 121, -14, 23, -44, -4, -68, -49, -105, 108, -107, -4, 91, -57, -77, -71, 110, -39, 44, 5, -16, -19, 31, -101, 112, 48, 68, -25, -61, 39]
y: [60, 50, -90, 106, -59, -72, 81, -52, 11, 103, 7, -31, 94, -98, 71, 115, 64, -73, -65, -105, -98, -123, 24, 59, 59, 52, -29, 105, -57, 102, 126, 96]
17:04:49.879 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [90, -80, 108, -124, -91, -14, 48, 99, 95, 105, -73, -70, 88, 14, -79, -4, -65, -122, -47, 30, -38, -2, -101, -19, 65, -98, 19, 55, 123, 88, 91, 23]
y: [8, -78, 79, 53, 9, 96, 40, 82, -121, 76, 12, 60, 12, -113, -17, 103, 127, -121, -80, 4, -82, -101, -93, -81, 27, 17, -127, -70, 74, 20, 120, 36]
17:04:49.881 [main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.27.0
17:04:49.885 [main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
17:04:49.885 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `null`
17:04:49.886 [main] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT
17:04:49.886 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `SOME`
17:04:49.886 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<kex done>>
17:04:49.886 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT
17:04:49.886 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Negotiated algorithms: [ kex=curve25519-sha256; sig=ssh-ed25519; c2sCipher=aes128-ctr; s2cCipher=aes128-ctr; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none ]
17:04:49.886 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Sending SSH_MSG_KEXDH_INIT
17:04:49.890 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received kex followup data
17:04:49.891 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Received SSH_MSG_KEXDH_REPLY
17:04:49.891 [reader] DEBUG net.schmizz.sshj.common.KeyType - Key algo: ssh-ed25519, Key curve: 25519, Key Len: 32
p: [44, 106, 18, 44, -29, -51, 2, -46, -95, -8, -43, 56, 103, 113, 48, 17, 16, -50, 118, 96, 61, 55, -16, -77, 109, 11, 117, 38, -82, 96, -87, -52]
17:04:49.892 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts'}
17:04:49.892 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts2'}
17:04:49.892 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with net.schmizz.sshj.transport.verification.FingerprintVerifier$1@1ea7f3fe
17:04:49.892 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_NEWKEYS
17:04:49.892 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_NEWKEYS
17:04:49.896 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `null`
17:04:49.896 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `SOME`
17:04:49.896 [main] DEBUG net.schmizz.sshj.SSHClient - Key exchange took 0.011 seconds
17:04:49.900 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp521, Key curve: nistp521, Key Len: 133, 0x04: 4
x: [1, -115, 3, 4, -10, -64, 14, -117, 112, -28, -82, -80, -20, -56, -73, -55, -89, 4, -50, -78, 27, -38, 97, -41, 17, 64, 72, -11, -96, 72, -66, 113, 10, -104, -20, -92, -66, -122, 88, -79, 27, -28, 115, -81, -117, -14, -53, 118, -7, 81, 32, -75, -93, -77, 32, 66, 12, 106, 44, -39, -98, -99, -70, -76, 45, 31]
y: [1, -94, 118, -103, 102, -29, 125, 119, -4, 103, -72, 58, 90, -115, 85, -40, -87, -21, -17, 53, 23, 74, -67, -67, -111, -14, -34, -104, 105, -45, -40, -46, -89, -104, 105, 90, 62, 79, 84, 97, -96, 39, 20, -47, 30, 39, 42, 88, -40, -11, 8, -113, -105, 47, 51, 28, -121, 119, 58, -98, -81, 2, -45, 119, 81, 30]
17:04:49.900 [main] INFO com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Keypair is encrypted with: aes256-ctr, bcrypt, [0, 0, 0, 16, -123, -19, -55, -52, 69, 35, 118, 125, -5, -18, -23, -78, -121, -106, -111, -96, 0, 0, 0, 16]
17:04:50.024 [main] INFO com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Read key type: ecdsa-sha2-nistp521
17:04:50.025 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp521, Key curve: nistp521, Key Len: 133, 0x04: 4
x: [1, -115, 3, 4, -10, -64, 14, -117, 112, -28, -82, -80, -20, -56, -73, -55, -89, 4, -50, -78, 27, -38, 97, -41, 17, 64, 72, -11, -96, 72, -66, 113, 10, -104, -20, -92, -66, -122, 88, -79, 27, -28, 115, -81, -117, -14, -53, 118, -7, 81, 32, -75, -93, -77, 32, 66, 12, 106, 44, -39, -98, -99, -70, -76, 45, 31]
y: [1, -94, 118, -103, 102, -29, 125, 119, -4, 103, -72, 58, 90, -115, 85, -40, -87, -21, -17, 53, 23, 74, -67, -67, -111, -14, -34, -104, 105, -45, -40, -46, -89, -104, 105, 90, 62, 79, 84, 97, -96, 39, 20, -47, 30, 39, 42, 88, -40, -11, 8, -113, -105, 47, 51, 28, -121, 119, 58, -98, -81, 2, -45, 119, 81, 30]
17:04:50.029 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to `null`
17:04:50.029 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth
17:04:50.029 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<service accept>>
17:04:50.030 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to `SOME`
17:04:50.030 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-userauth
17:04:50.030 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to `null`
17:04:50.030 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Trying `publickey` auth...
17:04:50.030 [main] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@43af351a
17:04:50.031 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<authenticated>>
17:04:50.036 [reader] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Asking `publickey` method to handle USERAUTH_60 packet
17:04:50.036 [reader] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Key acceptable, sending signed request
17:04:50.036 [reader] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@43af351a
17:04:50.065 [reader] ERROR net.schmizz.sshj.transport.TransportImpl - Dying because - null
java.lang.ArrayIndexOutOfBoundsException: null
at java.lang.System.arraycopy(Native Method)
at net.schmizz.sshj.signature.SignatureECDSA.encode(SignatureECDSA.java:96)
at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putSig(KeyedAuthMethod.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.sendSignedReq(AuthPublickey.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.handle(AuthPublickey.java:45)
at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:142)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
17:04:50.066 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - UNKNOWN
17:04:50.066 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Got notified of net.schmizz.sshj.common.SSHException
17:04:50.066 [reader] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Notified of net.schmizz.sshj.common.SSHException
17:04:50.066 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to null-service
17:04:50.066 [main] ERROR net.schmizz.concurrent.Promise - <<authenticated>> woke to: net.schmizz.sshj.userauth.UserAuthException
17:04:50.066 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to `SOME`
17:04:50.066 [reader] DEBUG net.schmizz.sshj.transport.Reader - Stopping
17:04:50.066 [main] DEBUG Test - Failure!
net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:230)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:345)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:363)
at Test.create(Test.java:84)
at Test.main(Test.java:97)
Caused by: net.schmizz.sshj.userauth.UserAuthException: null
at net.schmizz.sshj.userauth.UserAuthException$1.chain(UserAuthException.java:33)
at net.schmizz.sshj.userauth.UserAuthException$1.chain(UserAuthException.java:26)
at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
at net.schmizz.sshj.userauth.UserAuthImpl.notifyError(UserAuthImpl.java:156)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:601)
at net.schmizz.sshj.transport.Reader.run(Reader.java:65)
Caused by: net.schmizz.sshj.common.SSHException: null
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:36)
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:29)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:595)
... 1 common frames omitted
Caused by: java.lang.ArrayIndexOutOfBoundsException: null
at java.lang.System.arraycopy(Native Method)
at net.schmizz.sshj.signature.SignatureECDSA.encode(SignatureECDSA.java:96)
at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putSig(KeyedAuthMethod.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.sendSignedReq(AuthPublickey.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.handle(AuthPublickey.java:45)
at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:142)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
Exception in thread "main" net.schmizz.sshj.userauth.UserAuthException: authentication failed: Exhausted available authentication methods
at Test.create(Test.java:88)
at Test.main(Test.java:97)
Caused by: net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:230)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:345)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:363)
at Test.create(Test.java:84)
... 1 more
Caused by: net.schmizz.sshj.userauth.UserAuthException
at net.schmizz.sshj.userauth.UserAuthException$1.chain(UserAuthException.java:33)
at net.schmizz.sshj.userauth.UserAuthException$1.chain(UserAuthException.java:26)
at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
at net.schmizz.sshj.userauth.UserAuthImpl.notifyError(UserAuthImpl.java:156)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:601)
at net.schmizz.sshj.transport.Reader.run(Reader.java:65)
Caused by: net.schmizz.sshj.common.SSHException
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:36)
at net.schmizz.sshj.common.SSHException$1.chain(SSHException.java:29)
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:595)
... 1 more
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at net.schmizz.sshj.signature.SignatureECDSA.encode(SignatureECDSA.java:96)
at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putSig(KeyedAuthMethod.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.sendSignedReq(AuthPublickey.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.handle(AuthPublickey.java:45)
at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:142)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
Disconnected from the target VM, address: '127.0.0.1:55015', transport: 'socket'
Process finished with exit code 1
If needed, I created my key pair with following command:
ssh-keygen -t ecdsa -b 521
And my private key is in he form of
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
Hello again, I tried with PEM file on 521 bit but still doesn't work.
I just find that I can authenticate as expected using 256 bit ECDSA key with the same code piece. So maybe there is something wrong ongoing with 521 bit (Which I believe the array copy part on is the root cause at net.schmizz.sshj.signature.SignatureECDSA.encode(SignatureECDSA.java:96)). I put the working log as well maybe you can distinguish something
12:18:25.179 [main] INFO net.schmizz.sshj.transport.random.BouncyCastleRandom - Generating random seed from SecureRandom.
12:18:25.181 [main] DEBUG net.schmizz.sshj.transport.random.BouncyCastleRandom - Creating random seed took 0 ms
12:18:25.211 [main] DEBUG net.schmizz.sshj.DefaultConfig - Available cipher factories: [aes128-cbc, aes128-ctr, aes192-cbc, aes192-ctr, aes256-cbc, aes256-ctr, blowfish-cbc, blowfish-ctr, cast128-cbc, cast128-ctr, idea-cbc, idea-ctr, serpent128-cbc, serpent128-ctr, serpent192-cbc, serpent192-ctr, serpent256-cbc, serpent256-ctr, 3des-cbc, 3des-ctr, twofish128-cbc, twofish128-ctr, twofish192-cbc, twofish192-ctr, twofish256-cbc, twofish256-ctr, twofish-cbc, arcfour, arcfour128, arcfour256]
12:18:25.245 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [61, 22, 17, -6, -121, -45, -123, 23, -35, 54, -118, 22, -59, 86, -26, -62, 110, -14, -39, 89, 106, -5, 95, -53, 103, -86, 114, 95, 50, 27, -52, -23]
y: [3, -56, -84, 113, -54, -96, 84, 49, -98, -29, 94, -99, 39, 62, -40, -118, -56, 66, 123, -71, 102, -49, 34, -31, 1, 22, -79, 86, -125, -84, 35, -87]
12:18:25.334 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [-94, 95, -57, -96, 126, -116, -78, -113, -33, 116, -26, -19, -8, 95, -14, -126, -68, -76, -43, -105, -87, -114, 118, 115, -92, -91, -44, -18, 8, 11, -104, -23]
y: [103, 122, 114, 82, 60, -1, -110, -53, -97, -2, 10, 19, -94, -96, -87, -113, 32, -79, 21, 89, 64, -85, -44, -78, -14, 40, -110, -18, 124, 77, 37, -43]
12:18:25.334 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [20, 43, -124, -81, 51, -13, 50, 126, 58, 17, 18, 107, -75, -102, 76, -83, 64, -120, 43, -36, 42, 4, 39, 62, 66, 82, 83, 109, -35, 47, -44, 94]
y: [-75, -51, -107, -14, 90, -113, -17, -126, 53, -89, -46, 119, -92, -89, 71, 85, -49, -101, -31, -125, 71, -81, 14, -94, 0, 38, -27, 51, -88, -19, 74, 30]
12:18:25.335 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [66, -71, -48, 41, 27, 59, 6, 109, 113, 1, 2, 119, -96, -60, -127, 1, 46, -124, 100, -105, 13, -61, 84, 102, 13, 116, -89, -62, 116, 5, -22, -55]
y: [-36, -98, 76, -107, -94, 104, 126, 94, -17, 100, 113, 113, 5, 0, -69, 104, 21, 66, 53, 78, -97, 13, 0, -11, -96, 63, -35, 45, -19, -89, -97, -124]
12:18:25.335 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [13, -17, -106, 74, 79, 82, 11, -17, 85, 27, -80, -44, -14, -34, 75, -97, 69, -102, -65, -27, 92, -67, 21, -87, 56, 84, 77, 109, 14, -10, -53, -83]
y: [56, -46, -22, 56, 111, 4, 29, -68, -59, 64, 87, 50, 70, -58, -54, 19, 102, 66, -93, -87, 12, -96, -15, -43, 37, 10, -119, -6, -80, 124, 108, 10]
12:18:25.335 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [57, -96, -110, 121, -14, 23, -44, -4, -68, -49, -105, 108, -107, -4, 91, -57, -77, -71, 110, -39, 44, 5, -16, -19, 31, -101, 112, 48, 68, -25, -61, 39]
y: [60, 50, -90, 106, -59, -72, 81, -52, 11, 103, 7, -31, 94, -98, 71, 115, 64, -73, -65, -105, -98, -123, 24, 59, 59, 52, -29, 105, -57, 102, 126, 96]
12:18:25.336 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [90, -80, 108, -124, -91, -14, 48, 99, 95, 105, -73, -70, 88, 14, -79, -4, -65, -122, -47, 30, -38, -2, -101, -19, 65, -98, 19, 55, 123, 88, 91, 23]
y: [8, -78, 79, 53, 9, 96, 40, 82, -121, 76, 12, 60, 12, -113, -17, 103, 127, -121, -80, 4, -82, -101, -93, -81, 27, 17, -127, -70, 74, 20, 120, 36]
12:18:25.338 [main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.27.0
12:18:25.345 [main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
12:18:25.345 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `null`
12:18:25.345 [main] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT
12:18:25.347 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT
12:18:25.347 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `SOME`
12:18:25.348 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<kex done>>
12:18:25.348 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Negotiated algorithms: [ kex=curve25519-sha256; sig=ssh-ed25519; c2sCipher=aes128-ctr; s2cCipher=aes128-ctr; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none ]
12:18:25.361 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Sending SSH_MSG_KEXDH_INIT
12:18:25.372 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received kex followup data
12:18:25.372 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Received SSH_MSG_KEXDH_REPLY
12:18:25.372 [reader] DEBUG net.schmizz.sshj.common.KeyType - Key algo: ssh-ed25519, Key curve: 25519, Key Len: 32
p: [44, 106, 18, 44, -29, -51, 2, -46, -95, -8, -43, 56, 103, 113, 48, 17, 16, -50, 118, 96, 61, 55, -16, -77, 109, 11, 117, 38, -82, 96, -87, -52]
12:18:25.392 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts'}
12:18:25.392 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts2'}
12:18:25.392 [reader] ERROR net.schmizz.sshj.transport.KeyExchanger - Disconnecting because none of the configured Host key verifiers ([OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts'}, OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts2'}]) could verify 'ssh-ed25519' host key with fingerprint xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx for x.x.x.x:22
12:18:25.393 [reader] ERROR net.schmizz.sshj.transport.TransportImpl - Dying because - Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
net.schmizz.sshj.transport.TransportException: Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
at net.schmizz.sshj.transport.KeyExchanger.verifyHost(KeyExchanger.java:211)
at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:365)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:503)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
12:18:25.394 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - HOST_KEY_NOT_VERIFIABLE
12:18:25.394 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Got notified of net.schmizz.sshj.transport.TransportException: [HOST_KEY_NOT_VERIFIABLE] Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
12:18:25.394 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl$NullService - Notified of net.schmizz.sshj.transport.TransportException: [HOST_KEY_NOT_VERIFIABLE] Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
12:18:25.394 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to null-service
12:18:25.394 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_DISCONNECT: reason=[HOST_KEY_NOT_VERIFIABLE], msg=[Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22]
12:18:25.394 [main] ERROR net.schmizz.concurrent.Promise - <<kex done>> woke to: net.schmizz.sshj.transport.TransportException: [HOST_KEY_NOT_VERIFIABLE] Could not verify `ssh-ed25519` host key with fingerprint `xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx` for `x.x.x.x` on port 22
12:18:25.395 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to `SOME`
12:18:25.395 [reader] DEBUG net.schmizz.sshj.transport.Reader - Stopping
12:18:25.395 [main] INFO net.schmizz.sshj.transport.random.BouncyCastleRandom - Generating random seed from SecureRandom.
12:18:25.395 [main] DEBUG net.schmizz.sshj.transport.random.BouncyCastleRandom - Creating random seed took 0 ms
12:18:25.399 [main] DEBUG net.schmizz.sshj.DefaultConfig - Available cipher factories: [aes128-cbc, aes128-ctr, aes192-cbc, aes192-ctr, aes256-cbc, aes256-ctr, blowfish-cbc, blowfish-ctr, cast128-cbc, cast128-ctr, idea-cbc, idea-ctr, serpent128-cbc, serpent128-ctr, serpent192-cbc, serpent192-ctr, serpent256-cbc, serpent256-ctr, 3des-cbc, 3des-ctr, twofish128-cbc, twofish128-ctr, twofish192-cbc, twofish192-ctr, twofish256-cbc, twofish256-ctr, twofish-cbc, arcfour, arcfour128, arcfour256]
12:18:25.399 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [61, 22, 17, -6, -121, -45, -123, 23, -35, 54, -118, 22, -59, 86, -26, -62, 110, -14, -39, 89, 106, -5, 95, -53, 103, -86, 114, 95, 50, 27, -52, -23]
y: [3, -56, -84, 113, -54, -96, 84, 49, -98, -29, 94, -99, 39, 62, -40, -118, -56, 66, 123, -71, 102, -49, 34, -31, 1, 22, -79, 86, -125, -84, 35, -87]
12:18:25.400 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [-94, 95, -57, -96, 126, -116, -78, -113, -33, 116, -26, -19, -8, 95, -14, -126, -68, -76, -43, -105, -87, -114, 118, 115, -92, -91, -44, -18, 8, 11, -104, -23]
y: [103, 122, 114, 82, 60, -1, -110, -53, -97, -2, 10, 19, -94, -96, -87, -113, 32, -79, 21, 89, 64, -85, -44, -78, -14, 40, -110, -18, 124, 77, 37, -43]
12:18:25.400 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [20, 43, -124, -81, 51, -13, 50, 126, 58, 17, 18, 107, -75, -102, 76, -83, 64, -120, 43, -36, 42, 4, 39, 62, 66, 82, 83, 109, -35, 47, -44, 94]
y: [-75, -51, -107, -14, 90, -113, -17, -126, 53, -89, -46, 119, -92, -89, 71, 85, -49, -101, -31, -125, 71, -81, 14, -94, 0, 38, -27, 51, -88, -19, 74, 30]
12:18:25.400 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [66, -71, -48, 41, 27, 59, 6, 109, 113, 1, 2, 119, -96, -60, -127, 1, 46, -124, 100, -105, 13, -61, 84, 102, 13, 116, -89, -62, 116, 5, -22, -55]
y: [-36, -98, 76, -107, -94, 104, 126, 94, -17, 100, 113, 113, 5, 0, -69, 104, 21, 66, 53, 78, -97, 13, 0, -11, -96, 63, -35, 45, -19, -89, -97, -124]
12:18:25.400 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [13, -17, -106, 74, 79, 82, 11, -17, 85, 27, -80, -44, -14, -34, 75, -97, 69, -102, -65, -27, 92, -67, 21, -87, 56, 84, 77, 109, 14, -10, -53, -83]
y: [56, -46, -22, 56, 111, 4, 29, -68, -59, 64, 87, 50, 70, -58, -54, 19, 102, 66, -93, -87, 12, -96, -15, -43, 37, 10, -119, -6, -80, 124, 108, 10]
12:18:25.401 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [57, -96, -110, 121, -14, 23, -44, -4, -68, -49, -105, 108, -107, -4, 91, -57, -77, -71, 110, -39, 44, 5, -16, -19, 31, -101, 112, 48, 68, -25, -61, 39]
y: [60, 50, -90, 106, -59, -72, 81, -52, 11, 103, 7, -31, 94, -98, 71, 115, 64, -73, -65, -105, -98, -123, 24, 59, 59, 52, -29, 105, -57, 102, 126, 96]
12:18:25.401 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [90, -80, 108, -124, -91, -14, 48, 99, 95, 105, -73, -70, 88, 14, -79, -4, -65, -122, -47, 30, -38, -2, -101, -19, 65, -98, 19, 55, 123, 88, 91, 23]
y: [8, -78, 79, 53, 9, 96, 40, 82, -121, 76, 12, 60, 12, -113, -17, 103, 127, -121, -80, 4, -82, -101, -93, -81, 27, 17, -127, -70, 74, 20, 120, 36]
12:18:25.402 [main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.27.0
12:18:25.407 [main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
12:18:25.407 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `null`
12:18:25.407 [main] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT
12:18:25.407 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `SOME`
12:18:25.408 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<kex done>>
12:18:25.408 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT
12:18:25.408 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Negotiated algorithms: [ kex=curve25519-sha256; sig=ssh-ed25519; c2sCipher=aes128-ctr; s2cCipher=aes128-ctr; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none ]
12:18:25.409 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Sending SSH_MSG_KEXDH_INIT
12:18:25.419 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received kex followup data
12:18:25.419 [reader] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Received SSH_MSG_KEXDH_REPLY
12:18:25.419 [reader] DEBUG net.schmizz.sshj.common.KeyType - Key algo: ssh-ed25519, Key curve: 25519, Key Len: 32
p: [44, 106, 18, 44, -29, -51, 2, -46, -95, -8, -43, 56, 103, 113, 48, 17, 16, -50, 118, 96, 61, 55, -16, -77, 109, 11, 117, 38, -82, 96, -87, -52]
12:18:25.421 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts'}
12:18:25.421 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with OpenSSHKnownHosts{khFile='/home/alperenp/.ssh/known_hosts2'}
12:18:25.421 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with net.schmizz.sshj.transport.verification.FingerprintVerifier$1@4759857b
12:18:25.421 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_NEWKEYS
12:18:25.421 [reader] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_NEWKEYS
12:18:25.424 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `null`
12:18:25.424 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `SOME`
12:18:25.424 [main] DEBUG net.schmizz.sshj.SSHClient - Key exchange took 0.017 seconds
12:18:25.427 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [-28, 23, 81, 54, -12, 126, 88, -23, -116, -29, -81, -23, 68, -126, -92, -41, 93, 15, -9, 127, 124, -36, -48, -71, -40, 50, 101, -61, 12, 69, 13, -9]
y: [47, 63, -49, 2, -121, -119, -100, -119, 46, 60, 56, 50, 17, -59, -29, 68, 63, 66, -73, 36, 113, -14, -82, -5, 84, -113, -34, 71, 43, 71, 97, -88]
12:18:25.427 [main] INFO com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Keypair is encrypted with: aes256-ctr, bcrypt, [0, 0, 0, 16, 111, 78, -59, 29, 59, -62, 59, -86, 86, 95, 83, -15, 107, 117, -43, -91, 0, 0, 0, 16]
12:18:25.550 [main] INFO com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Read key type: ecdsa-sha2-nistp256
12:18:25.550 [main] DEBUG net.schmizz.sshj.common.ECDSAVariationsAdapter - Key algo: ecdsa-sha2-nistp256, Key curve: nistp256, Key Len: 65, 0x04: 4
x: [-28, 23, 81, 54, -12, 126, 88, -23, -116, -29, -81, -23, 68, -126, -92, -41, 93, 15, -9, 127, 124, -36, -48, -71, -40, 50, 101, -61, 12, 69, 13, -9]
y: [47, 63, -49, 2, -121, -119, -100, -119, 46, 60, 56, 50, 17, -59, -29, 68, 63, 66, -73, 36, 113, -14, -82, -5, 84, -113, -34, 71, 43, 71, 97, -88]
12:18:25.552 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to `null`
12:18:25.553 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth
12:18:25.553 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<service accept>>
12:18:25.554 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to `SOME`
12:18:25.554 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-userauth
12:18:25.554 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to `null`
12:18:25.554 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Trying `publickey` auth...
12:18:25.554 [main] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@66e8997c
12:18:25.555 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<authenticated>>
12:18:25.560 [reader] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Asking `publickey` method to handle USERAUTH_60 packet
12:18:25.561 [reader] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Key acceptable, sending signed request
12:18:25.561 [reader] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@66e8997c
12:18:25.572 [reader] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-connection
12:18:25.572 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to `true`
12:18:25.572 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - `publickey` auth successful
12:18:26.018 [reader] DEBUG net.schmizz.sshj.connection.ConnectionImpl - Received GLOBAL_REQUEST `hostkeys-00@openssh.com`; want reply: false
Hello again, Is there any update planned regarding with the issue? Or you need further information/investigation? Best,
This issue appears to be resolved in PR #623.
Hey there, I've been using sshj for some time, thanks for such nice tool and continue on your improvements! I encounter a problem when I try to use ecdsa-sha2-nistp521 key. This could be duplicate issue but I couldn't find it from previous issues and in other public sources.
Here is the deal, I have a private ECDSA key and a remote server which I can connect successfully over ssh. While using sshj, I receive
Here is how I try to do the magic
Possibly related: On my first trial of SSHClient creation, I receive the following (when calling connect(ip, port, poxy) method) and then I try to create with the fingerpint.
I've tried adding BouncyCastle as
Security.addProvider(new BouncyCastleProvider());
however, it didn't change the result. If you can give a hand, it would be appreciated!Specifications: