I have an interesting problem.

I'd like to use a private SSH key with my Android Terminal Emulator (jackpal.androidterm). I'd like to install the private key in a fairly-secure location and be able to access the key in a fairly straightforward way. I'd like to do this:

ssh theotherserver

With a ~/.ssh/config file looking like this:

Host theotherserver
    User mycustomuser

And the private key being read from ~/.ssh/id_rsa.

The problem is that Dropbear by default looks in /data/.ssh (at least here on CyanogenMod 11) and this folder is meant to be owned by root. I've done a chown and chmod on the directory and its children to be able to use it with the "app user" which is u0_a100, and that works, but these permissions are wiped on reboot: so no go.

What I'd really like to do is to simply tell Dropbear via a configuration file that its home lives in /data/data/jackpal.androidterm/app_HOME/.ssh, as this directory will be 'for sure' owned by the "app user" and I won't run into any permissions issues. An added benefit is that other users won't be able to read this directory as it is private to the application. (dir permissions is drwxrwx--x) Is there a way to configure Dropbear with a configuration file to change the location of its default .ssh directory? It would be awesome if it just used $HOME, but it's obviously not.

If that is impossible, how can I compile OpenSSH client or Dropbear for Android in a way that would enable me to achieve my (seeming simple) goal?

  • first idea. is it possible that you symlink from /data/.ssh to /data/data/jackpal.androidterm/app_HOME/.ssh. Should Workaround the permission- and locationproblem. – xx4h Jun 11 '14 at 4:39
  • Let me try that. – Naftuli Kay Jun 11 '14 at 4:40
  • Welp, that worked. – Naftuli Kay Jun 11 '14 at 4:55

As @xx4h mentioned in the comments to the question, a solution was to symlink /data/.ssh to /data/data/jackpal.androidterm/app_HOME/.ssh:

# ln -s /data/data/jackpal.androidterm/app_HOME/.ssh /data/.ssh

That fixed it and remains in place after a reboot. Export an environment variable to make it easy to modify SSH config:


Either that or just drop another symlink in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.