Installation of ssh server for debian-in-android (gnuroot)

Update (2014-11-20): After rebooting the phone, the the sshd (openssh-server) failed to start again (some error message like “chroot /var/run/sshd” failed). So the reliable way is still using dropbear.

Update (2014-11-06): I can install openssh-server successfully under gunroot.  No special tricks (don’t why it failed in my first trial) except changing the port to > 1024 (/etc/ssh/sshd_config) and chmod og-rwx /etc/ssh/*.  After the modification, issue /etc/init.d/ssh start

Unlike traditional debian machine, you cannot install/run openssh-server inside a debain-in-android (gnuroot).  However, dropbear can be used instead.

Steps:

– Install android app GNURoot.

– Install android app, GNURoot Wheezy.

– Inside Debian terminal, install dropbear (apt-get intall dropbear).

– Modify /etc/default/dropbear and change the DROPBEAR_PORT to anything > 1024.

– (Update on 2014-07-04) Start the dropbear: /etc/init.d/dropbear start

Advertisements

6 comments

  1. Great article! I try it, but after it seems to accept my password successfully it then says “Connection to xxx.xxx.xxx.xxx closed.” I tried it from two other machines then even noticed that it does it from the phone itself when I try it from JuiceSSH. I used port 1111

    1. Did you try “netstat -an|grep 1111”? Was dropbear listening to 1111 port?
      Are you sure the password is correct? I just tried to change the port to 1111 and works flawlessly. You can change to another port to try.

      Which user you tested? To test “root” user the file /etc/ssh/dropbear should contain “PermitRootLogin yes”. For other user, you may verify the user’s home folder, shell, etc in /etc/passwd.

      When you start/restart dropbear, did you notice any message like

      Restarting Dropbear SSH server: dropbear.

      Some router may block client to client access. You may have a look.

  2. To be able to log in using openssh-server, I had to replace
    “UsePrivilegeSeparation yes”
    with
    “UsePrivilegeSeparation no”
    in sshd_config file

    otherwise, sshd refuse inbound connections with this message (when run interactively in debug mode):
    chroot(“/var/run/sshd”): Operation not permitted [preauth]

  3. I got both dropbear and openssh-server running, but whenever I connect with putty the server sends a message “Server refused to allocate pty” and I don’t get a shell. In the case of dropbear, the connection drops, while with openssh-server I seem to remain connected but can’t actually do anything.

    Any suggestions? I poked around online for similar issues, and they mostly involved setting permissions on, or recreating /dev/pty and the like, but when I tried that I didn’t have correct permissions (even as fake root in GNUroot).

    1. Access to /dev is denied by SELinux, therefore sshd can’t allocate a pseudoterminal.

      You can still run programs directly, e.g.: ssh -p … root@… “apt-get update && apt-get dist-upgrade -y”

      SFTP also works fine.

  4. Is there any way to make the dropbear service run automatically when I open the GNURoot terminal window? so I dont have to type ‘service dropbear start’ each time?
    Tried the “Initial Command” property from the GNURoot app properties, but it doesn’t seem to work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s