SimpleSSHD
SimpleSSHD is an SSH2 server based on dropbear that supports scp,
sftp, and rsync. It only supports public-key based authentication (no
password/interactive auth except for bootstrapping). It does not use
root, which means it must listen on a port over 1024 (defaults to port
2222).
Quick start
- Install SimpleSSHD.
- On any computer which will connect to your Android device, set the
port to 2222. With OpenSSH, this can be done by putting these lines in
~/.ssh/config:
Host myphone
Port 2222
- Launch SimpleSSHD, and in Settings enable "Start on Boot", then
manually start it for the first time.
- Create /sdcard/ssh/authorized_keys
- Optionally make /sdcard/ssh/.profile
If SimpleSSHD does not find an authorized_keys file when a
client connects, then it generates a single-use password at that time and
displays it in the console log. So the procedure to login the first time
is to initiate the ssh connection, then look at the phone and type in the
password that is on the screen in the SimpleSSHD app. It is recommended
to use that shell session to install the authorized_keys
file.
Once authorized_keys exists, only public key authentication
is supported. If you screw up your authorized_keys file, use
the options menu (upper right) -> Reset Keys.
Settings
Generally speaking, you must re-start the SimpleSSHD service for any
of these settings to take effect.
- Start on Boot
- Automatically start the SimpleSSHD service when the phone powers on.
- Foreground Service
- Run the SimpleSSHD service as an Android "foreground service." This
means a notification will be displayed for the service (you might be able
to block the notification by long tapping the notification).
On newer versions of Android (since Marshmallow), this may also make
SimpleSSHD more responsive if the phone has been in Doze mode. It does
not seem to increase battery consumption much.
- Start on Open
- Run the SimpleSSHD service whenever the app is launched. The "STOP"
button will be replaced with a "QUIT" button that stops the service and
exits the app. This is useful if you want to only run the service when
you really need it -- start the app to start listening for connections,
and then click "QUIT" when you are done.
- Port Number
- This is the port number that SimpleSSHD will listen on. It must be
greater than 1024 (because SimpleSSHD does not have root).
- SSH Path
- Path for general dropbear files, which defaults to
/sdcard/ssh. Most importantly, this is where
authorized_keys is found. It is also where host keys wind up
(they are created on demand), and where temporary files go. This path
should probably be under /sdcard.
- Login Shell
- Path to the command shell. The default Android shell is
/system/bin/sh, but you may prefer to use the one that comes with
busybox or whatever. If you set it to the su binary (i.e.,
/system/xbin/su), then scp, sftp, and rsync will run as root and
should be able to access files outside of the sdcard.
- Buffer hack for rsync+SuperSU
- A bug in SuperSU interacts with an infelicity in rsync to cause an
occasional deadlock. This is a real pain because I use SuperSU+rsync
for system-wide backups, which will always eventually trigger the
deadlock. To work around this, there is a "Buffer hack" option that
should be enabled if you use rsync with SuperSU. It adds a miniscule
overhead to rsync, but isn't harmful even if you aren't using
SuperSU.
- Home Directory
- The login shell's home directory, which also defaults
to /sdcard/ssh. This is where your ssh session starts out, and is
where .profile will be found if it is present.
- Extra Commandline
- You can specify additional commandline options for dropbear server.
The options which are hardcoded are:
-R -F -p :portno
You can use \ or " to escape characters in this
commandline.
Change Log
- 2016/10/17 Version 15: Fix crash on pre-Nougat versions of Android.
- 2016/10/16 Version 14: Support single-use passwords for
bootstrapping.
- 2016/10/16 Version 13: Support foreground service (fewer
stalls with newer Android). Add "Start on Open" mode.
- 2016/08/08 Version 1.11: Fix stall initializing random number generator.
- 2016/07/22 Version 1.10: Enable TCP port forwarding.
- 2016/07/04 Version 1.9: Restart sshd if the system kills it.
- 2016/06/21 Version 1.8: sftp, rsync, and scp now work on
files bigger than 2GB.
- 2016/06/19 Version 1.7: Don't clear environment variables (so
you can use am or pm more easily). Add "Authorized
Keys" menu option to help maintain the authorized_keys file.
- 2016/06/12 Version 1.6: Fix typo that broke scp/sftp/rsync in
version 1.5.
- 2016/06/11 Version 1.5: SuperSU+rsync hack now limits the
buffer size to 1MB.
- 2015/11/23 Version 1.4: Don't abort if IP address lookup fails, and make proper "About" menu.
- 2015/06/21 Version 1.3: Hack to make rsync work with SuperSU.
- 2015/01/18 Version 1.2: Displays the IP address it's listening on.
- 2014/12/29 Version 1.1: Works with Lollipop now.
- 2014/12/22 Version 1.0: Initial public release.
About
SimpleSSHD is built using parts from open source projects:
Dropbear SSH,
openssh (for scp and sftp-server),
and rsync. Those projects in turn
are built on other projects. A lot of people's work is represented here,
and very little of my own.
But if you find bugs/infelicities, it's probably my fault, so email
me:
To get the source:
git clone http://galexander.org/git/simplesshd.git