Using SSH from Android

SSH is a protocol used to run commands securely in a remote machine. In my dissertation I needed to invoke latex commands in a remote machine the user mentions from an Android app. I explain the steps below to connect to a remote machine through SSH from an Android app. We will be using SSHJ API to do this. SSHJ is an open source Java implementation of the SSH protocol.

The steps involved in using the SSH protocol are as follows

  1. Include the library files in the build path.
    • Download the latest version of the SSHJ library from
    • Extract the zip file and copy the “sshj-0.8.1.jar” into the libs directory of your android project.
    • Include the dependencies of the SSHJ library also in the build path.
      • SLF4J – logging library. (slf4j-api-1.6.99.jar, slf4j-simple-1.6.99.jar)
      • Bounty Castle – Security library. (bcpkix-jdk15on-147.jar, bcprov-jdk15on-147.jar)
      • JZlib – Compression library. ()
    • Include the above mentioned jar files also into the lib folder of the Android project.
  2. To use username and password authentication use a NullHostKeyVerifier like the below one.

import net.schmizz.sshj.transport.verification.HostKeyVerifier;

public class NullHostKeyVerifier implements HostKeyVerifier {

* This method is used to bypass HostKeyVerification.
* It returns true for whatever the input is.
public boolean verify(String arg0, int arg1, PublicKey arg2) {
return true;
  1. Then use the below code to connect to a remote machine and to execute a command in a remote machine and to get the output of the command in the remote machine.
// creates new SSH client
final SSHClient ssh = new SSHClient(new AndroidConfig());
Command cmd = null;

// Adds a nullHostKeyVerifier
ssh.addHostKeyVerifier(new NullHostKeyVerifier());

// default port number
int pn = 22;

// connect to the machine
try {
ssh.connect(ipaddress, pn);
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);

// Authenticate with the password entered
ssh.authPassword(username, password);

// start a new session
final Session session = ssh.startSession();

// runs the commands in the remote machine
cmd = session.exec("ls");

// reads the output of the command
result = IOUtils.readFully(cmd.getInputStream()).toString();

I have excluded the try catch from the code.
Note: Line number 2 is the difference in using the code from a Java application and from the Android application.

Enhanced by Zemanta

FOSS vs Open Source

When I was preparing to move to England to do my higher studies, I googled for the local user communities and joined the Leicester Linux User Group. There were a lot of interesting discussions going on there. One particular day there was a mail saying “Richard Stallman”, the so called “Father of Open Source” was visiting Leicester to give a speech in De-Mont Fort Univeristy.


I was so interested in it. I along with my another friend were in the hall much before Richard visited the hall. Richard was a simple man with a different ideology. He spoke about FOSS movement and how it differed from Open Source movement of Linus Torvaldus. That was the first time I ever knew there was a difference between the both movements.

Richard started his speech by mentioning that not to post photos and videos of the sessions in Facebook. He said tagging peoples photos can be used as a way of surveillance. Found it true. So what I did. Deleted all the photos I uploaded on facebook. He asked whatever content of the session that is to be published in the internet must be creative commons attributed. Then he started preaching his philosophy about Free and Open Source Software movement.


Richard Stallman

Richard Stallman

From what Richard mentioned I would make that Linus and Open Source movement guys are more pragmatic and Richard is more philosophical. Richard was against using the closed source NVidia driver in Ubuntu, whereas Linus or Open Source movement is open to use closed source applications as a part of the application.

Richard then spoke how iPod and Kindle doesn’t allow users to use the devices with freedom. I was able to get his point when I tried to sync music into my newly bought iPod from my Ubuntu box. It seriously sucks.

At the end of the session, he started speaking about Emacs. Which I didn’t even understand a bit. I rarely use emacs and never knew what he was saying about.

At the question session someone asked him about Google. He said he enjoys few products of the Google and hates few products for its privacy policy.

At the end of the session he gave away few stickers and I left the hall with a different perspective of Open Source and the FOSS philosophy.

I should thank the Leicester LUG and the De-Mont Fort guys. The session was awesome.

Enhanced by Zemanta

How I translated Wallch to Tamil

Wallch is a Ubuntu app which allows your desktop wallpaper to change automatically.

There was an invitation to translate it into any language of your choice here 

I just wanted to give a shot. So translated the app into Tamil and have mailed the developers and am waiting for a reply.

It’s simple to translate any app into other languages if planned well. This app uses Qt linguist to translate the app. I used google translate from English to Tamil.

Enhanced by Zemanta

Chennai Bus Routes

Few weeks back, I started learning Android programming. My MSc dissertation is to develop an Android app for Latex. I don’t know much Android programming. So I started exploring it. Randomly I came across Phonegap. When I was exploring it a bit I felt it would be easy to convert an existing webapp into android native app with phonegap. To try that I took an existing website


I worked on the app for 3 days and the end product is here. I used Phonegap and Jquery Mobile. The major issue I feel with the app is it takes much time to load the auto-complete. I have also released the code in github.

Chennai Bus Routes

Chennai Bus Routes

So by the end of three days I fulfilled one of my long desires to host an app in Android market. Did it at last. It is as of now used by more than 100+ users.

App statistics

App statistics

I will be working to add more features when I get some free time.

You can get the app from this link

Get it on Google Play

 Please leave as comments if you need any more features.


Enhanced by Zemanta