0

I am trying to create an Android app to connect via SSH to a Dell PowerConnect switch to perform straightforward tasks on command (for example, turn off/on POE for a port to remote reset a POE device). I am using the SSHJ library but can't get it to authenticate.

I finally found how to get SSHJ to list accepted authentication types after a failure, and it returns a single option (publickey). However, SSH connections via Linux and putty both work using username/password authentication. The Dell switch also doesn't offer anything to change how it replies to connection attempts that I've been able to find (not surprising, but I checked just in case).

Here's my code:

    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);

        session = ssh.startSession();

My error log shows:

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 

Is there a way to force username/password authentication? Or am I looking at this all wrong?

Thale
  • 3
  • 3

1 Answers1

0

You cannot force password authentication onto a server that does not support it. The output you have provided appears to suggest the server only supports publickey authentication.

Either that, or it also requires publickey authentication in addition to the username/password.

  • I think one can ask the server about allowed authentication methods with this: `ssh.getUserAuth().getAllowedMethods()` which can be triggered after unsuccessful authentication. – Jokkeri Aug 06 '19 at 11:36