Code Monkey home page Code Monkey logo

dropbear-android's Introduction

Android Dropbear

A patch set and script to download and cross-compile Dropbear SSH server for use on Android with password authentication. As the 64-bit binaries don't seem to work reliably, this project is configured to compile 32-bit binaries using the Android NDK toolchain.

Generated binares will all be PIE (position indepedent executable) binaries as it is required on Android 5 (L/ollipop).

If building for android < 4.1 then before building, issue:

export DISABLE_PIE=1

Building Dropbear for Android

The process consists of just four parts:

  1. Specify the version of Dropbear you'd like to download and crosscompile. Open build-android-dropbear.sh and change the value of VERSION at the top, which defaults to 2018.76
  2. Build your standalone android toolchain.
    See the android developer site for more info: https://developer.android.com/ndk/guides/standalone_toolchain.html
  3. Export your toolchain's location:
export TOOLCHAIN=/path/to/standalone/toolchain
  1. Run the build script:
./build-dropbear-android.sh

Generated binaries will be outputted to {android dropbear repo directory}/target/arm

Customizations

Much of the project is pre-configured with sane defaults, but if you'd like to customize the behavior of Dropbear for Android, here are a few tips.

  1. To change/configure most options, look in and modify the following files as appropriate:
    a) default_options.h
    b) sysoptions.h
    c) config.h

For instance, to change the port Dropbear runs on or to change the default location in which Dropbear tries to generate keys, edit default_options.h and modify the respective values.

Basic usage

Dropbear for Android adds a few special flags to Dropbear:

  • A: signifies Android mode and allows for password authentication in the absence of the crypt() lib
  • G: allows us to specify the GID dropbear should run as
  • U: allows us to specify the UID dropbear should run as
  • N: specify the login username for the session
  • T: specify the authentication key for the session

A typical usecase would be:

./dropbear -d /path/to/dropbear_dss_host_key -r /path/to/dropbear_rsa_hostkey -p 10022 -P /path/to/dropbear.pid -R -A -N user -C password -U u0_aXX -G u0_aXX

The above command will run the Dropbear server with password authentication enabled for the user 'user' with password 'password' and will attempt to run as u0_aXX and in that group. More information can be found by issuing:

./dropbear --help

Credits

Big thanks to mkj who has been maintaining Dropbear:
https://github.com/mkj/dropbear

Thanks to NHellfire who's work made the process of getting 2018.76 up and running much easier:
https://github.com/NHellFire/dropbear-android

Thanks to jmfoy for the config.sub and config.guess files:
https://github.com/jfmoy/android-dropbear

Another thank you to the various other repositories out there whose various approches helped lead to this completed project.

dropbear-android's People

Contributors

mhausbermel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropbear-android's Issues

Failed to open any /dev/pty?? devices

Hi
I have problem from subject. I'm trying to run it (on android box with 4.2.2 android version, rooted of course ;) ) as follows:
dropbear -d path_to_dss_key -r p path_to_rsa_key -r path_to_ecdsa_key -p 22 -P path_to_pid -R -N user -C password -U root -G root -A -F

Error log:
...
Failed to open any /dev/pty?? devices
No pty was allocated, couldn't execute
....

Compilation doesn't start with android-ndk-r18b arm64

  1. Download Android NDK r18b.

  2. Create stand-alone toolchain. For example, ~/android-ndk-r18b/build/tools/make_standalone_toolchain.py --arch arm64 -v --install-dir ~/android-toolchain64.

  3. export TOOLCHAIN=~/android-toolchain64

  4. ./build-dropbear-android.sh. The build script silently exits after Generating required files....

Upon closer look, modifying variables in build-dropbear-android.sh finished the build.

HOST=aarch64-linux-android
COMPILER=${TOOLCHAIN}/bin/aarch64-linux-android-gcc
STRIP=${TOOLCHAIN}/bin/aarch64-linux-android-strip

Compilation fails with android-ndk-r17b

Here's the error log:

/home/max/Development/Linux/toolchain-arm/bin/arm-linux-androideabi-gcc --sysroot=/home/max/Development/Linux/toolchain-arm/sysroot -Wl,-pie -Wl,-z,now -Wl,-z,relro -o dropbear dbutil.o buffer.o dbhelpers.o dss.o bignum.o signkey.o rsa.o dbrandom.o queue.o atomicio.o compat.o fake-rfc2553.o ltc_prng.o ecc.o ecdsa.o crypto_desc.o gensignkey.o gendss.o genrsa.o common-session.o packet.o common-algo.o common-kex.o common-channel.o common-chansession.o termcodes.o loginrec.o tcp-accept.o listener.o process-packet.o dh_groups.o common-runopts.o circbuffer.o curve25519-donna.o list.o netio.o svr-kex.o svr-auth.o sshpty.o svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o svr-tcpfwd.o svr-authpam.o libtomcrypt/libtomcrypt.a libtommath/libtommath.a  
dbutil.c:139: error: undefined reference to 'stderr'
dbutil.c:361: error: undefined reference to 'signal'
dbutil.c:280: error: undefined reference to 'signal'
dbrandom.c:92: error: undefined reference to '__FD_SET_chk'
/home/max/Development/Linux/toolchain-arm/sysroot/usr/include/bits/fortify/unistd.h:406: error: undefined reference to '__read_chk'
/home/max/Development/Linux/toolchain-arm/sysroot/usr/include/bits/fortify/string.h:391: error: undefined reference to '__strlen_chk'
/home/max/Development/Linux/toolchain-arm/sysroot/usr/include/bits/fortify/string.h:391: error: undefined reference to '__strlen_chk'
gendss.c:66: error: undefined reference to 'stderr'
genrsa.c:133: error: undefined reference to 'stderr'
genrsa.c:91: error: undefined reference to 'stderr'
common-session.c:157: error: undefined reference to '__FD_SET_chk'
common-session.c:174: error: undefined reference to '__FD_SET_chk'
common-session.c:180: error: undefined reference to '__FD_SET_chk'
common-session.c:206: error: undefined reference to '__FD_ISSET_chk'
common-session.c:218: error: undefined reference to '__FD_ISSET_chk'
common-session.c:414: error: undefined reference to '__FD_ISSET_chk'
common-channel.c:219: error: undefined reference to '__FD_ISSET_chk'
/home/max/Development/Linux/toolchain-arm/sysroot/usr/include/bits/fortify/string.h:391: error: undefined reference to '__strlen_chk'
sshpty.c:219: error: undefined reference to 'tcgetattr'
sshpty.c:228: error: undefined reference to 'tcsetattr'
sshpty.c:274: error: undefined reference to 'signal'
svr-chansession.c:159: error: undefined reference to 'sigemptyset'
svr-chansession.c:1047: error: undefined reference to 'sigemptyset'
svr-chansession.c:817: error: undefined reference to 'signal'
svr-chansession.c:481: error: undefined reference to 'tcgetattr'
svr-chansession.c:553: error: undefined reference to 'tcsetattr'
svr-main.c:394: error: undefined reference to 'sigemptyset'
svr-main.c:352: error: undefined reference to 'sigemptyset'
bn_mp_rand.c:36: error: undefined reference to 'rand'
bn_mp_rand.c:36: error: undefined reference to 'rand'
bn_mp_rand.c:36: error: undefined reference to 'rand'
bn_mp_rand.c:36: error: undefined reference to 'rand'
collect2: error: ld returned 1 exit status
make: *** [Makefile:177: dropbear] Fehler 1

Not really sure what I could be doing wrong..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.