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?
Asked
Active
Viewed 1.6k times
2 Answers
10
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 [email protected]
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.

eldarerathis
- 36,787
- 16
- 144
- 175
6
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
.

iOS
- 12,381
- 13
- 63
- 103
-
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 06: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)? – iOS 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. – iOS 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
$HOME
(for root) is set to/data
on my phone, butssh
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:20echo $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. – iOS Apr 28 '12 at 09:07