[Nexus 7 (2013) General] wolfdude:
Hi all,

This is an update to my previous post on compiling an earlier version of dropbear SSH. This post has been updated with a new patch and some minor changes to the steps to work with dropbear-2016.73 (latest as of Apr-04 2016). My previous post can be found here :-

http://xdaforums.com/nexus-7-2013/general/guide-compiling-dropbear-2015-67-t3142412

** START DISCLAIMER **

I did not write the original codes/patch myself and have not scrutinized it for any security issues. USE IT AT YOUR OWN RISK.

** END DISCLAIMER **

Here's the list of requirements :-

1) Dropbear 2016.73 source code - dropbear-2016.73.tar.bz2 (https://matt.ucc.asn.au/dropbear/dropbear-2016.73.tar.bz2)

2) Patch to compile for Android - dropbear-2016.73-patch-20160403 (https://goo.gl/y07TnH).

3) A recent Linux distro (I use Ubuntu 14.04.4 LTS).

4) Development tools i.e. C compiler, linker, etc... all the necessary tools to run configure, make, etc..

5) Android NDK (I'm using rev 11c) installed & setup on Linux.

Steps :-

(1) Extract the source code to a directory of its own :-

tar xjf dropbear-2016.73.tar.bz2
cd dropbear-2016.73

(2) Patch the source :-

patch -p1 < ../dropbear-2016.73-patch-20160403

(3) Run configure :-

./configure --build=x86_64-unknown-linux-gnu --host=arm-linux-androideabi \
--disable-zlib --disable-largefile --disable-loginfunc \
--disable-shadow --disable-utmp --disable-utmpx --disable-wtmp \
--disable-wtmpx --disable-pututline --disable-pututxline --disable-lastlog

(4) Edit config.h, add the following lines and comment/delete the line that defines HAVE_OPENPTY :-

#define USE_DEV_PTMX 1
#define HAVE_GETUSERSHELL 1
#define HAVE_GETPASS 1
/* #define HAVE_OPENPTY 1 */

(5) Run make :-

STATIC=1 MULTI=1 SCPPROGRESS=1 PROGRAMS="dropbear dropbearkey scp dbclient" make strip

(6) You should end up with a single static binary "dropbearmulti" which you should link dropbear, dbclient/ssh, dropbearkey and scp to.

lrwxrwxrwx root root 2016-04-04 20:56 dbclient -> dropbearmulti
lrwxrwxrwx root root 2016-04-04 20:56 dropbear -> dropbearmulti
lrwxrwxrwx root root 2016-04-04 20:56 dropbearkey -> dropbearmulti
-rwxr-xr-x root root 650352 2016-04-04 20:55 dropbearmulti
lrwxrwxrwx root root 2016-04-04 20:56 scp -> dropbearmulti
lrwxrwxrwx root root 2016-04-04 20:56 ssh -> dropbearmulti

Dropbear server v2016.73 https://matt.ucc.asn.au/dropbear/dropbear.html
Usage: dropbear [options]
-A Android Mode, specify a user explicitly
-N Android Mode, user name
-C Android Mode, password
-R Android Mode, public key file (authorized_keys)
-U Android Mode, UID
-G Android Mode, GID
-b bannerfile Display the contents of bannerfile before user login
(default: none)
-r keyfile Specify hostkeys (repeatable)
defaults:
dss /etc/dropbear/dropbear_dss_host_key
rsa /etc/dropbear/dropbear_rsa_host_key
ecdsa /etc/dropbear/dropbear_ecdsa_host_key
-F Don't fork into background
-E Log to stderr rather than syslog
-m Don't display the motd on login
-w Disallow root logins
-j Disable local port forwarding
-k Disable remote port forwarding
-a Allow connections to forwarded ports from any host
-p [address:]port
Listen on specified tcp port (and optionally address),
up to 10 can be specified
(default port is 22 if none specified)
-P PidFile Create pid file PidFile
(default /var/run/dropbear.pid)
-i Start for inetd
-W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)
-K <keepalive> (0 is never, default 0, in seconds)
-I <idle_timeout> (0 is never, default 0, in seconds)
-V Version

Cheers.