hierynomus / hierynomus/sshj

Connection with Dell switch fails auth

Open
#522 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.7k
Forks
620
Avg merge
3d 23h
Merged PRs (30d)
11

Description

I am new to SSHJ and trying to connect to Dell PowerConnect switches with authPassword to execute standard tasks for troubleshooting (for example, bounce POE on a single port to reset a device remotely). I can establish the connection, but auth fails with:
W/System.err: net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods

I can connect with putty and from a Linux box using username & password authentication. I found how to get allowed auth methods after a failure, and it only reports "publickey". How to I override that or force a connection using username & password like putty does?

**************************************************
Here's my code:
public static String executeRemoteSSHJ(String username,String password,String hostname,int port) throws Exception{
String stringempty = ""; //Provide option for returning empty string

final SSHClient ssh = new SSHClient();

Command cmd = null; //declare

try {
ssh.loadKnownHosts();
} catch (IOException e) {
e.printStackTrace();
}

ssh.addHostKeyVerifier(new PromiscuousVerifier());
ssh.connect(hostname,port);

Session session = null;

try {

ssh.authPassword(username, password);
ssh.auth

session = ssh.startSession();

cmd = session.exec("show int status");

cmd.join(5, TimeUnit.SECONDS);

Log.i("TESTING", "\n exit status: " + String.valueOf(cmd.getExitStatus())); //TESTING

} catch (ConnectionException e) {
e.printStackTrace(); //Print all the information about the error that occurred
return stringempty;
} catch (TransportException e) {
e.printStackTrace(); //Print all the information about the error that occurred
return stringempty;
} catch (UserAuthException e) {
e.printStackTrace(); //Print all the information about the error that occurred
return stringempty;
} catch (Exception e) {
e.printStackTrace(); //Print all the information about the error that occurred
return stringempty;
} finally {
try {
// TESTING: This block -- tell me what authentication methods are allowed!
Iterable testresult = ssh.getUserAuth().getAllowedMethods(); //TESTING
for (String i : testresult) {
Log.i("TESTRESULT", i); //TESTING
}
//END TESTING

if (session != null) {
session.close();
}
} catch (IOException e) {
// Do Nothing
}
ssh.disconnect();
}

return cmd.getInputStream().toString();

}

******************************************************
Here's my log file:
I/TransportImpl: Client identity string: SSH-2.0-SSHJ_0.27.0
I/TransportImpl: Server identity string: SSH-2.0-OpenSSH_5.9p1.RL
W/System.err: net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:230)
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:205)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:291)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:261)
W/System.err: at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:245)
at net.metalx.myapplication.MainActivity.executeRemoteSSHJ(MainActivity.java:405)
at net.metalx.myapplication.MainActivity$2.doInBackground(MainActivity.java:216)
at net.metalx.myapplication.MainActivity$2.doInBackground(MainActivity.java:204)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
I/TESTRESULT: publickey
I/TransportImpl: Disconnected - BY_APPLICATION

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.