hierynomus / sshj

ssh, scp and sftp for java
Apache License 2.0
2.51k stars 601 forks source link

Can not authenticate to server #422

Open tomaskir opened 6 years ago

tomaskir commented 6 years ago

Greetings,

Getting login failure against an Araknis switch. I can login to this device without an issue with Putty with the same credentials.

This same code works fine with other devices (Cisco, HP, etc.).

Code used:

final SSHClient sshClient = new SSHClient(new DefaultConfig());
sshClient.addHostKeyVerifier(new PromiscuousVerifier());

try {
    sshClient.setConnectTimeout(timeout);
    sshClient.connect(address, port);

    sshClient.authPassword(user, pass);
} catch ...

Log:

net.schmizz.sshj.transport.KeyExchanger  : Trying to verify host key with net.schmizz.sshj.transport.verification.PromiscuousVerifier@a2ca8d7
net.schmizz.sshj.transport.KeyExchanger  : Sending SSH_MSG_NEWKEYS
n.schmizz.sshj.transport.TransportImpl   : Received packet NEWKEYS
net.schmizz.sshj.transport.KeyExchanger  : Received SSH_MSG_NEWKEYS
net.schmizz.sshj.SSHClient               : Key exchange took 1.253 seconds
n.schmizz.sshj.transport.TransportImpl   : Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth
n.schmizz.sshj.transport.TransportImpl   : Received packet SERVICE_ACCEPT
n.schmizz.sshj.transport.TransportImpl   : Setting active service to ssh-userauth
net.schmizz.sshj.userauth.UserAuthImpl   : Trying `password` auth...
n.s.sshj.userauth.method.AuthPassword    : Requesting password for [AccountResource] user@host
n.schmizz.sshj.transport.TransportImpl   : Received packet USERAUTH_FAILURE
net.schmizz.sshj.userauth.UserAuthImpl   : `password` auth failed
net.schmizz.sshj.userauth.UserAuthImpl   : Trying `keyboard-interactive` auth...
n.schmizz.sshj.transport.TransportImpl   : Received packet USERAUTH_FAILURE
net.schmizz.sshj.userauth.UserAuthImpl   : `keyboard-interactive` auth failed
n.schmizz.sshj.transport.TransportImpl   : Disconnected - BY_APPLICATION
net.schmizz.sshj.userauth.UserAuthImpl   : Notified of net.schmizz.sshj.transport.TransportException: [BY_APPLICATION] Disconnected
n.schmizz.sshj.transport.TransportImpl   : Sending SSH_MSG_DISCONNECT: reason=[BY_APPLICATION], msg=[]
net.schmizz.sshj.transport.Reader        : Stopping

Any idea what could be wrong or how to further debug this?

Thanks!

hierynomus commented 6 years ago

As there is an USERAUTH_FAILURE, I would recommend revisiting the credentials. They might've been mistyped.

Else please provide trace logging.

tomaskir commented 6 years ago

Sadly I no longer have access to the switch this issue was present on.

Credentials were correct, I checked multiple times.