7

I would like to install DropBear SSH on my 64 bit Android 5.1 device, but it seems that all the installation tutorials and how-tos have disappeared or contain links to broken files/downloads.

Could someone please explain the proper way to accomplish this?

FURTHER DETAILS:

  • This question comes from this other: an attempt to install some SSH Server on a modern (September 2015 at least) Android device that has (nearly) failed with many tested apps. Command line installation of Dropbear is a different approach to the problem.
8
  • 1
    Note to potential close-voters: OP isn't asking for an app, but wants installation help. Sopalajo comes here on my suggestion, the "is there an app for X" part was/is already dealt with at SR. OP knows about where to find it – the question asked here is how to make it fly.
    – Izzy
    Commented Sep 15, 2015 at 21:34
  • 1
    I hope it is all right now, @Izzy. The link is added, I have no trustworthy sources for the Dropbear code, and all I have tried are apps, not command-line methods. Commented Sep 15, 2015 at 22:44
  • The link is there (to SR), where I've left a link to the busybox.net binaries download page (so you don't need to fiddle with an installer additionally). Doing that manually, you'd need to create all those symlinks to the main binary (at least those you want). What's available it tells you when calling it without any parameters. You should place the binary in /system/xbin, and create the symlinks in the same place. I just cannot tell you further for the "how to get sshd running" part.
    – Izzy
    Commented Sep 15, 2015 at 22:51
  • @Izzy, do those versions of BusyBox include the Dropbear binaries? Commented Sep 15, 2015 at 23:04
  • 1
    The bad part, @Izzy, is: maybe as for today (September 2015) the new 64 bit cores are too recent and will have compatibility issues with not-too-recent apps and low-level programs like OpenSSH and Dropbear. Commented Sep 15, 2015 at 23:48

2 Answers 2

7

First as a side-note for other readers: We're not talking about "an app" here (those have already been tried and didn't work on that architecture), but about a command-line binary. DropBear sometimes is part of Busybox, or it comes as separate binary.


Now for the installation part. Binaries you install yourself best go to /system/xbin, which is in the $PATH but usually "initially empty" (Android's own stuff is in /system/bin and /system/sbin), so we run a very low risk of "collisions". So either adb shell or terminal to your device and make sure you're root. I further assume you've already transferred the dropbear/busybox binary to your SD card.

mount -o remount,rw /system        # make sure we can write to system
cp /sdcard/busybox /system/xbin    # copy the binaries to /system/xbin
cp /sdcard/dropbear /system/xbin
cd /system/xbin                    # switch to our target directory
chmod 755 busybox dropbear         # make sure we've set the correct permissions
busybox --install /system/xbin     # advice busybox to create all its symlinks here

Installation part done (skip the dropbear parts here if your dropbear comes with busybox – and vice versa, skip the busybox part if not needed.

Now, we need to make dropbear fly. I've never tried this myself, so I refer to an external script at Github for that. In short (and in case that link dies), again assuming the required files are already copied to your SD card:

# Creating a home-dir for DropBear
mkdir /data/dropbear
chmod 755 /data/dropbear
mkdir /data/dropbear/.ssh
chmod 700 /data/dropbear/.ssh
# Copy over our files
mv /sdcard/authorized_keys /data/dropbear/.ssh/
chown root: /data/dropbear/.ssh/authorized_keys
chmod 600 /data/dropbear/.ssh/authorized_keys
# Generate a hostkey, so we can use DropBear
dropbearkey -t rsa -f /data/dropbear/dropbear_rsa_host_key
dropbearkey -t dss -f /data/dropbear/dropbear_dss_host_key

An additional part if you want DropBear to auto-start at boot:

cat << EOF >> /etc/init.local.rc

# start Dropbear (ssh server) service on boot
service sshd /system/xbin/dropbear -s
   user  root
   group root
   oneshot

EOF

Note that this assumes your device supports init.d scripts. First check for the availability of that file to make sure.

Finally, don't forget to make /system read-only again. Either reboot at this point (so you also can check that DropBear starts as intended), or at least execute

mount -o remount,ro /system

for now, postponing the reboot. To start the service manually, it should be possible executing that block via some shell script (so you could e.g. have a task for starting and another one for stopping the daemon, and even make shortcuts to those tasks on your homescreen for manual control). Again, I have not tested this part, so it's "pure theory".

Good luck with DropBear and BusyBox!

2
  • So I understand that, after the installation procedure, the command line to start the SSH service should be /system/xbin/dropbear -s ? And I presume it could be run as root (via su) or normal user, of course. Commented Sep 16, 2015 at 11:23
  • I've tried this and it works. There's no ready dropbear binary (at least I haven't found one) so you have to config and make a source like this one: github.com/ubiquiti/dropbear-android (changing the version to a newer one doesn't seem to work so keep it at 2018.76 or you'll have to edit the patch)
    – kidroca
    Commented Oct 10, 2023 at 14:32
5

Install Termux (Google Play, F-Droid, Fossdroid)

apt update
apt ugpgrade
apt install dropbear

I personally chose OpenSSH toover Dropbear

apt install openssh

To run the server

sshd

Unless your device is rooted you won't be able to run sshd as root. Note that running as non-root implies that ports below 1024 cannot be bound to. In Termux any packages have been configured to have compatible default values - the ftpd, httpd, and sshd servers default to 8021, 8080 and 8022, respectively.

If you want to run sshd as root try this script: https://gist.github.com/cycojesus/57409ffed9066ce7f4d4

At that point you will be able to bind sshd to port 22.

2
  • Link to GitHub is dead. Commented Sep 16, 2018 at 10:47
  • What would be and how can you set in this case the username and password to log in, SFTP, SCP... etc? Commented Sep 16, 2018 at 10:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .