SSH Maverick connection with Android

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Oct 31, 2016, 7:26:15 PM via Website

Hello Together,
I have a Problem by Programming a ssh connection between pc and android phone.
I already wrote the code and i ran it in eclipse and there it works.
Now i copy and pasted it into android studio and it is running with an error.
I am using Maverick SSH2 example code

The Problem : i use the command executeCommand("echo > help.txt") and in eclipse the programm sends the command and finishs.
In contrast to Android Studio, when i use executeCommand there it sends ("echo > help.txt"), too but still stays in executeCommand. All Commands after this wont be called. It stucks in the command.

Does anyone has an idea ?
I dont know what to do, i thought when it is running in eclipse it has to run in android studio as well.

Thanks for Help!


the Code:

import com.sshtools.ssh.ChannelOpenException;
import com.sshtools.ssh.PasswordAuthentication;
import com.sshtools.ssh.SshAuthentication;
import com.sshtools.ssh.SshClient;
import com.sshtools.ssh.SshConnector;
import com.sshtools.ssh.SshException;
import com.sshtools.ssh.SshSession;
import com.sshtools.util.IOStreamConnector;


* Created by Zouca on 31.10.2016.

class SSH implements Runnable {

public void run() {
    //Code wich should be run
    try {

        SshConnector con = SshConnector.createInstance();
        SshClient ssh;

        ssh = con.connect(new SocketTransport("192......", 22),

        PasswordAuthentication pwd = new PasswordAuthentication();

        if(ssh.authenticate(pwd)== SshAuthentication.COMPLETE)
        {System.out.println("Authentication succeeded");}

        SshSession session = ssh.openSessionChannel();

        session.executeCommand("echo > hello.txt");


    catch (SshException | IOException | ChannelOpenException e) {

        System.out.println("Authentication failed");

    System.out.println("!!! I came to the End ! Never seen this at console :( !!");



Recommended articles