ssh command in android app
<p>I'm new in Android app Dev.
I'm trying to connect my app to an ssh server and execute a simple command.
I wrote this code, No errors, no problem during execution on my Galaxy, but the command isn't executed. Any help would be appreciated. Thanks</p>

<pre><code>package com.example.testcomando;

import java.io.ByteArrayOutputStream;
import java.util.Properties;
import com.jcraft.jsch.*;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends Activity {

public static String executeRemoteCommand(
            String username,
            String password,
            String hostname,
            int port) throws Exception {     

JSch jsch = new JSch();
Session session = jsch.getSession(username, hostname, 22);
session.setPassword(password);

// Avoid asking for key confirmation
Properties prop = new Properties();
prop.put("StrictHostKeyChecking", "no");
session.setConfig(prop);

session.connect();

// SSH Channel
ChannelExec channelssh = (ChannelExec) 
                session.openChannel("exec");      
ByteArrayOutputStream baos = new ByteArrayOutputStream();
channelssh.setOutputStream(baos);

// Execute command
channelssh.setCommand("touch z.txt");
channelssh.connect();        
channelssh.disconnect();

return baos.toString();
}

    Button add;
    String str;
    TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        add=(Button)findViewById(R.id.button1);
        tv=(TextView)findViewById(R.id.textView1);


add.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                try {
                    str=executeRemoteCommand("root","pass","http://kkkk.nnn.org",22);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                     tv.setText(str);


            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
</code></pre>
