Using ConnectBot with Intents

Is there any way to access the ConnectBot functionality via intents? I want to start a ssh-session out of my application and authenticate via Private/Public Key, and close the session afterwards. Is this possible with ConnectBot and if yes, how can I call the Intents? Sadly, I didn't find any documentation on this topic :(


The answer to this question depends on what you want to use the ssh session for: is it something programmatic, or do you want to show the user a terminal session or console where they can type in arbitrary commands? That second option is for the most part quite easily supported, as you can see from studying the ConnectBot manifest - the app has an intent filter registered for the ConsoleActivity which matches this pattern:

  • action : android.intent.action.VIEW
  • uri : ssh://user@host:port/#nickname won't close the session afterwards, but apart from that, it will do everything you specified, using ConnectBot's own infrastructure for the connection, and employing any SSH keys the user has registered within the ConnectBot app.

Alternatively, you might be talking about the former option: for your app to execute some particular command against an SSH server in a programmatic fashion.

This isn't currently supported in any way by the official release of ConnectBot. Depending on your requirements, you might imagine that you would just fire off an intent to ConnectBot with the address of a server and a command you want it to execute; that wouldn't be too hard for ConnectBot to implement and it would save you the headache of learning too much about the ssh protocol. However, this intent doesn't exist, and if it did it would be very dangerous, any app on the phone could use it to execute arbitrary code with the users credentials on remote servers.

What does exist is this intent I created in a patched version of ConnectBot a few months ago to support Agit, the Git client for Android:


This patched version of ConnectBot allows ConnectBot to act like an ssh-agent - your app is responsible for managing the ssh connection, but you can call out to ConnectBot to obtain the necessary credentials - ConnectBot will let you know what public keys it has available for the connection, and will sign the digital challenges required for authentication. The details of the protocol are on, but basically you use the intent to bind to ConnectBot, obtaining an AIDL interface which provides the ssh-agent functionality:


As a security precaution, your app will need to declare that it uses this permission, or it won't be able to bind to the service:


The patched version of ConnectBot can be downloaded off the Android Market here:

The source code for the patch is here:

Although this takes care of the public/private key management, it still leaves you with actually having to implement the ssh connection within your app. I'd recommend the sshj library for ssh protocol support, see their example of a simple 'command' connection:

The Bouncy Castle crypto libs are normally used in Java for providing encryption algorithms, however the version provided with Android is crippled and not easily overridden - consequently you should use the Spongy Castle libs for an Android-friendly repackaging of the BC libs:

Need Your Help

How to debug NSInternalInconsistencyException trying to load nib that doesn't exist?

objective-c xcode4.3

2012-09-07 19:31:07.938 BadgerNew[2590:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle

How can I specify the return types in GCD blocks

objective-c ios ios4 objective-c-blocks grand-central-dispatch

How can i specify the return types in GCD blocks? Here I want to return my result as NSData ...

What is NSString internally?

nsstring spidermonkey

Can I assign a char* or wchar_t* to the NSString and completely avoid copying some how?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.