Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I'm using a rooted custom Android kernel (Gingerbread), and am able to connect to a remote SSH server with password authentication using busybox and a terminal emulator app. I would like to be able to use SSH keys for auto-login; is this possible? If so, where should I put my private key?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

It's not quite as seamless, but the ssh binary provided by busybox (mine, at least) supports the -i flag, so you can put the key wherever you want and use that:

ssh -i /path/to/key_file joeuser@somehost.com

The relevant man page entry for -i (with the caveat that the information about the default path may not be the same on Android):

-i identity_file

         Selects a file from which the identity (private key) for public
         key authentication is read.  The default is ~/.ssh/identity for
         protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and
         ~/.ssh/id_rsa for protocol version 2.  Identity files may also be
         specified on a per-host basis in the configuration file.  It is
         possible to have multiple -i options (and multiple identities
         specified in configuration files).  ssh will also try to load
         certificate information from the filename obtained by appending
         -cert.pub to identity filenames.
share|improve this answer
    
Thanks, I had thought of that, but never got around to trying it. It just seems strange that there is no place that the ssh command will look for the .ssh directory... maybe it's because there is no $HOME set? –  yuttadhammo Apr 27 '12 at 13:59
2  
@Yuttadhammo: The weird thing is that $HOME (for root) is set to /data on my phone, but ssh seems to ignore any directories I try to set up there. I've never really figured out why that is, but I haven't had a need to really dig into it, either. –  eldarerathis Apr 27 '12 at 14:20
    
@Yuttadhammo In my phone, echo $HOME returns nothing (even for root). If that's your case too, its the reason why your SSH client can't see keys by default. But, with -i flag, you can override the default path, so there's no point of looking $HOME. This is the correct solution if your trimmed down SSH client supports it. So, try it after putting keys on sdcard. If it fails, there's no other way unless you change SSH client. –  Sachin Shekhar Apr 28 '12 at 9:07

Install & run ConnectBot (a dedicated SSH client). Tap/press menu key. From the menu, tap Manage Pubkeys. On next screen, again press/tap menu key. From the menu, tap Import.

share|improve this answer
    
Thanks I actually just did that - nice app; is there no way to simply put a key somewhere and have busybox pick it up? –  yuttadhammo Apr 27 '12 at 6:17
    
@Yuttadhammo I don't think default packaging of Busybox provide SSH client. Can you be more specific with your SSH client (which may be external utility)? –  Sachin Shekhar Apr 27 '12 at 11:39
    
Also, remember.. as busybox applets are trimmed down version of original ones, your command line SSH client may not support authentication with key, but its very unlikely. Just tell me about your SSH client. –  Sachin Shekhar Apr 27 '12 at 11:40
    
Thanks, ConnectBot is the solution I'll be using, but the -i flag is really closer to answering the question. –  yuttadhammo Apr 28 '12 at 12:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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