Getting net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods #872
Closed
ashishiter
started this conversation in
General
Replies: 1 comment
-
Got this fixed by adding the approproate supported keyexchange to sshd_config file. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am able ssh to target server using regular ssh command . But when using sshj library getting the below error :
net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods.
The target server is a Microsoft OS running openssh server.
COmplete debug logs:
22:34:35.011 [main] INFO net.schmizz.sshj.transport.random.JCERandom - Creating new SecureRandom. 22:34:35.013 [main] DEBUG net.schmizz.sshj.transport.random.JCERandom - Random creation took 0 ms 22:34:35.050 [main] DEBUG net.schmizz.sshj.DefaultConfig - Available cipher factories: [[email protected], aes128-cbc, aes128-ctr, aes192-cbc, aes192-ctr, aes256-cbc, aes256-ctr, [email protected], [email protected], 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] 22:34:35.267 [main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.35.0 22:34:35.404 [main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.4 22:34:35.406 [main] DEBUG net.schmizz.sshj.SSHClient - Initiating Key Exchange for new connection 22:34:35.407 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to
null22:34:35.407 [main] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT 22:34:35.411 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to
SOME22:34:35.412 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<kex done>> 22:34:35.528 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT 22:34:35.530 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.KeyExchanger - Negotiated algorithms: [ kex=curve25519-sha256; sig=ssh-ed25519; c2sCipher=aes192-cbc; s2cCipher=aes192-cbc; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none; ] 22:34:35.574 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Sending SSH_MSG_KEXDH_INIT 22:34:35.694 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received kex followup data 22:34:35.694 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Received SSH_MSG_KEXDH_REPLY 22:34:35.695 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.common.KeyType - Key algo: ssh-ed25519, Key curve: 25519, Key Len: 32 p: [-114, -27, -103, -82, 7, -40, 99, -17, 47, -24, 100, 38, -54, -63, 76, 108, -113, 96, -71, 101, 50, 77, -89, 103, -31, 111, 46, -93, 27, 13, 100, -86] 22:34:35.724 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with net.schmizz.sshj.transport.verification.PromiscuousVerifier@59eb94f1 22:34:35.724 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_NEWKEYS 22:34:35.724 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_NEWKEYS 22:34:35.726 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to
null22:34:35.726 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to
SOME22:34:35.726 [main] DEBUG net.schmizz.sshj.SSHClient - Key exchange took 0.319 seconds 22:34:35.726 [main] DEBUG net.schmizz.sshj.SSHClient - Attempting to load key from: /Users/akumar053/vault/autobahn-svc-account/new-rsa-keyset-1/id-rsa 22:34:35.727 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_EXT_INFO 22:34:35.736 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to
null22:34:35.736 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth 22:34:35.737 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<service accept>> 22:34:35.998 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-userauth 22:34:35.998 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to
SOME22:34:36.002 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to
null22:34:36.002 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Trying
publickeyauth... 22:34:36.003 [main] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@27c6e487 22:34:36.004 [main] DEBUG com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Reading unencrypted keypair 22:34:36.004 [main] INFO com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Read key type: ssh-rsa 22:34:36.015 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<authenticated>> 22:34:36.743 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Asking
publickeymethod to handle USERAUTH_60 packet 22:34:36.744 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Key acceptable, sending signed request 22:34:36.744 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@27c6e487 22:34:36.895 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-connection 22:34:36.896 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to
true22:34:36.896 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl -
publickeyauth successful 22:34:36.903 [main] DEBUG net.schmizz.sshj.connection.ConnectionImpl - Attaching
direct-tcpipchannel (#0) 22:34:36.903 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<chan#0 / open>> 22:34:37.121 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.connection.ConnectionImpl - Received GLOBAL_REQUEST
[email protected]; want reply: false 22:34:37.122 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_DEBUG (display=false) 'Forced command.' 22:34:37.237 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_DEBUG (display=false) 'Forced command.' 22:34:37.242 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.connection.channel.direct.DirectConnection - Initialized - < direct-tcpip channel: id=0, recipient=0, localWin=[winSize=2097152], remoteWin=[winSize=2097152] > 22:34:37.242 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.concurrent.Promise - Setting <<chan#0 / open>> to
SOME22:34:37.243 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.connection.channel.Window$Local - Consuming by 33 down to 2097119 22:34:37.243 [main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.35.0 22:34:37.244 [main] DEBUG net.schmizz.sshj.connection.channel.Window$Remote - Consuming by 21 down to 2097131 22:34:37.244 [main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_for_Windows_9.2 22:34:37.249 [main] DEBUG net.schmizz.sshj.SSHClient - Initiating Key Exchange for new connection 22:34:37.249 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to
null22:34:37.249 [main] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT 22:34:37.250 [main] DEBUG net.schmizz.sshj.connection.channel.Window$Remote - Consuming by 2640 down to 2094491 22:34:37.250 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to
SOME22:34:37.250 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<kex done>> 22:34:37.427 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.connection.channel.Window$Local - Consuming by 1048 down to 2096071 22:34:37.428 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT 22:34:37.428 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.KeyExchanger - Negotiated algorithms: [ kex=curve25519-sha256; sig=ssh-ed25519; [email protected]; [email protected]; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none; ] 22:34:37.429 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Sending SSH_MSG_KEXDH_INIT 22:34:37.430 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.connection.channel.Window$Remote - Consuming by 48 down to 2094443 22:34:37.577 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.connection.channel.Window$Local - Consuming by 524 down to 2095547 22:34:37.578 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received kex followup data 22:34:37.578 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.kex.Curve25519SHA256 - Received SSH_MSG_KEXDH_REPLY 22:34:37.579 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.common.KeyType - Key algo: ssh-ed25519, Key curve: 25519, Key Len: 32 p: [-61, -30, -23, -69, 110, 58, 76, -41, 102, 105, -15, 43, -50, 101, -54, 82, 68, -12, -124, 96, 50, 95, 95, 55, 62, 118, 30, -20, -110, 123, 5, -87] 22:34:37.584 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.KeyExchanger - Trying to verify host key with net.schmizz.sshj.transport.verification.PromiscuousVerifier@1a041c32 22:34:37.585 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_NEWKEYS 22:34:37.585 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.connection.channel.Window$Remote - Consuming by 24 down to 2094419 22:34:37.585 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_NEWKEYS 22:34:37.586 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to
null22:34:37.587 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to
SOME22:34:37.587 [main] DEBUG net.schmizz.sshj.SSHClient - Key exchange took 0.338 seconds 22:34:37.587 [main] DEBUG net.schmizz.sshj.SSHClient - Attempting to load key from: /Users/akumar053/vault/autobahn-svc-account/new-rsa-keyset-1/id-rsa 22:34:37.587 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_EXT_INFO 22:34:37.592 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to
null22:34:37.592 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth 22:34:37.593 [main] DEBUG net.schmizz.sshj.connection.channel.Window$Remote - Consuming by 68 down to 2094351 22:34:37.593 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<service accept>> 22:34:37.877 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.connection.channel.Window$Local - Consuming by 44 down to 2095503 22:34:37.878 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-userauth 22:34:37.878 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to
SOME22:34:37.879 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to
null22:34:37.879 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Trying
publickeyauth... 22:34:37.879 [main] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@7fe8ea47 22:34:37.881 [main] DEBUG com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Reading unencrypted keypair 22:34:37.881 [main] INFO com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Read key type: ssh-rsa 22:34:37.884 [main] DEBUG net.schmizz.sshj.connection.channel.Window$Remote - Consuming by 1684 down to 2092667 22:34:37.884 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<authenticated>> 22:34:38.041 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.connection.channel.Window$Local - Consuming by 68 down to 2095435 22:34:38.043 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to
false22:34:38.043 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl -
publickeyauth failed 22:34:38.046 [main] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - BY_APPLICATION 22:34:38.046 [main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Notified of net.schmizz.sshj.transport.TransportException: [BY_APPLICATION] Disconnected 22:34:38.046 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_DISCONNECT: reason=[BY_APPLICATION], msg=[] 22:34:38.047 [main] DEBUG net.schmizz.sshj.connection.channel.Window$Remote - Consuming by 68 down to 2092599 22:34:38.048 [sshj-Reader-ec2-34-219-77-16.us-west-2.compute.amazonaws.com/34.219.77.16:22-1687833277248] DEBUG net.schmizz.sshj.transport.Reader - Stopping 22:34:38.048 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to
SOME22:34:38.049 [main] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - BY_APPLICATION 22:34:38.049 [main] DEBUG net.schmizz.sshj.connection.ConnectionImpl - Notified of net.schmizz.sshj.transport.TransportException: [BY_APPLICATION] Disconnected 22:34:38.050 [main] DEBUG net.schmizz.sshj.connection.channel.direct.DirectConnection - Channel #0 got notified of net.schmizz.sshj.transport.TransportException: [BY_APPLICATION] Disconnected 22:34:38.050 [main] DEBUG net.schmizz.sshj.connection.ConnectionImpl - Forgetting
direct-tcpipchannel (#0) 22:34:38.050 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<chan#0 / close>> to
SOME22:34:38.050 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_DISCONNECT: reason=[BY_APPLICATION], msg=[] 22:34:38.051 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to
SOME22:34:38.051 [sshj-Reader-jump.autobahn.comcast.com/96.118.251.38:22-1687833275406] DEBUG net.schmizz.sshj.transport.Reader - Stopping 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:393) at test.ssh.SSHJTestConnection.main(SSHJTestConnection.java:61)
Code ::
`package test.ssh;
import java.io.Console;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import org.slf4j.LoggerFactory;
import com.hierynomus.sshj.key.KeyAlgorithm;
import com.hierynomus.sshj.key.KeyAlgorithms;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import net.schmizz.sshj.Config;
import net.schmizz.sshj.DefaultConfig;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.common.Factory.Named;
import net.schmizz.sshj.connection.channel.direct.DirectConnection;
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
import net.schmizz.sshj.xfer.FileSystemFile;
/** This examples demonstrates how a remote command can be executed. */
public class SSHJTestConnection {
private static final Console con = System.console();
}`
Beta Was this translation helpful? Give feedback.
All reactions