Jump to content

sshd


Guest paulsmith

Recommended Posts

Guest paulsmith

Hi,

from a bit of google search I have discovered that dropbear ssh daemon can be installed onto android.

I was wondering if anyone could help me set this up? (or any other sshd ) - my rooted hero with MoDaCo custom rom doesn't seem to have telnetd either so it could be a lot of typing via the virtual keyboard :)

Also , inspite of there not being an rsync command for android - would rsync from a desktop computer to the android phone work?

Thanks in advance

Link to comment
Share on other sites

dropbear -A -N <USER> -U 0 -G 0 -C <PASSWORD> -r /system/etc/my_rsa_key -p 2222

this would start dropbear on port 2222, you can login with USER and PASSWORD or the key matching to /system/etc/my_rsa_key (you can skip the part "-r /system/etc/my_rsa_key " if you don't want to use a pubkey).

http://forum.xda-developers.com/showthread.php?t=442754

here is some more information, thanks to paul you don't have to deal with binarys 'n stuff. you have to create a host key by executing

dropbearkey -t rsa -f /system/etc/dropbear/dropbear_rsa_host_key
dropbearkey -t dss -f /system/etc/dropbear/dropbear_dss_host_key[/codebox]

on the phone via adb shell. if it doesn't work check if dropbear and dropbearkey are allowed to execute (adb shell chmod +x /system/xbin/dropbear*).

what i didn't figure out was the autostart-on-boot thing, the xda-devs thread deals with that and one user claims to have it solved, i lost interest at that point... :)

also i didn't get scp to work, which takes some of the fun out of it. please let me know if you can figure out either of these, feel free to ask if you have questions.

Link to comment
Share on other sites

Guest paulsmith

Thanks for the info people.

I think Im running Pauls MoDaCo Rom (perhaps 2.5.1 from Aug 26)

I looked in /system/bin and couldn't find dropbear - any idea where else to look?

I will look to upgrade to 2.6 version - the forum post for 2.5.1 has 71 pages! So Im not going to crawl through all of them.

Does anyone have a link to a 2.6 version of Pauls MoDaCo Rom?

Link to comment
Share on other sites

Guest paulsmith

Right, think I have a bit of success.

dropbear along with lots of other goodies (from busybox I guess) are located at:

/system/xbin

Using the Android SDK and adb shell to connect to the device I was able to execute some of the commands above.First problem was that I got permission denied errors for dropbear.

/system was mounted read only so I used:

# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

to remount it r/w

Then chmod worked.

I ran dropbear with the command in a previous post - and SSH login worked.

SCP did have problems , but that was also a permission denied error - chmod a+x on /system/xbin/scp seemed to fix that

SFTP probably doesn't which perhaps is the problem the previous poster encoutered.

I know ubuntu tries to use that when using SSH 'connect to server' from the gui

PaulS

Link to comment
Share on other sites

Guest paulsmith
Be patient :) The actual version is 2.5.1

Ah I see - I've only just got an android phone and thought 2.6 might be out already.

Will keep tabs on these forums - Im sure it will be discussed here.

Link to comment
Share on other sites

The 2.6.0 is here, but dropbear does not seem to be running automatically? Here is why I think it is not.

* nothing about it in release notes

* /etc/dropbear does not exist

* ps does not list it as a running process

+ the chmod and the remount of /system is not needed, thanks!

Dropbear is in ROM in 2.5.1, and from 2.6 onwards will be automatically running with your IMEI as the (changeable) password! :)

P

Link to comment
Share on other sites

Guest robin hansson

has anyone gotten this to work?

i'm unsure about what parameters to use with dropbear.

i've created rsa and dss host keys as described above.

tried starting dropbear like this: "dropbear -F -E"

it starts, and when i ssh to the phone using a non-root username i get a password prompt.

but i assume i'm supposed to login as root, right?

when i try ssh'ing to the phone with root as username, dropbear segfaults right after my ssh client has sent its pubkey;

debug2: we sent a publickey packet, wait for reply

Connection closed by 172.16.42.219

and dropbear shows this;

"Aiee, segfault! You should probably report this as a bug to the developer"

i've tried started dropbear using "-R authorized_keys2" (after putting my public key inside that file)

but that doesn't seem to help any.

what am i missing?

i'm running modaco 2.6 on a htc hero.

paul, are you working on a "admin gui" for dropbear or something?

Link to comment
Share on other sites

I can confirm that dropbear -A -N root -U 0 -G 0 -C somepass -R /system/etc/my_rsa_key -p 2222

works (note the -R instead of -r)

if -C somepass or -N not there, then it doesn't work.

What happens is that with the parameters you actually are setting up a temporary username and password (but can also use your privatekey to login).

has anyone gotten this to work?

i'm unsure about what parameters to use with dropbear.

i've created rsa and dss host keys as described above.

tried starting dropbear like this: "dropbear -F -E"

it starts, and when i ssh to the phone using a non-root username i get a password prompt.

but i assume i'm supposed to login as root, right?

when i try ssh'ing to the phone with root as username, dropbear segfaults right after my ssh client has sent its pubkey;

debug2: we sent a publickey packet, wait for reply

Connection closed by 172.16.42.219

and dropbear shows this;

"Aiee, segfault! You should probably report this as a bug to the developer"

i've tried started dropbear using "-R authorized_keys2" (after putting my public key inside that file)

but that doesn't seem to help any.

what am i missing?

i'm running modaco 2.6 on a htc hero.

paul, are you working on a "admin gui" for dropbear or something?

Link to comment
Share on other sites

well, have you tried starting dropbear like this:

dropbear -A -N <USER> -U 0 -G 0 -C <PASSWORD> -R /system/etc/my_rsa_key -p 2222

?

what happens? if it doesn't work, add the -F and -E switch, what is the output?

(note that if you don't have a keyfile just skip the " -R /system/etc/my_rsa_key" part, it works with only the password...)

Edited by kendon
Link to comment
Share on other sites

Guest robin hansson

thanks alot!

i created a simple shell script in /system/xbin/ called dropbear.sh containing this;

--- cut here ---

#!/system/bin/sh

dropbear -A -N root -U 0 -G 0 -C blah -R /etc/dropbear/auth

--- cut here ---

now i just need to figure out how to launch it without having to connect the usb cable and launching it through adb shell.

I can confirm that dropbear -A -N root -U 0 -G 0 -C somepass -R /system/etc/my_rsa_key -p 2222

works (note the -R instead of -r)

if -C somepass or -N not there, then it doesn't work.

What happens is that with the parameters you actually are setting up a temporary username and password (but can also use your privatekey to login).

Link to comment
Share on other sites

now i just need to figure out how to launch it without having to connect the usb cable and launching it through adb shell.

get a terminal emulator (eg connectbot) and start it via a local shell. not the most comfortable way, but should work.

Link to comment
Share on other sites

Guest robin hansson

thanks again!

sorry for spamming this thread, but i hate it when people just reply "oh, now it works for me!" in a thread, so i'd rather be verbose. :)

this is what i've done, and i'm pretty happy with it;

--- file /system/xbin/db (chmod +x db) ---

#!/system/bin/sh


if [ "$(id -u)" == "0" ]; then

  echo "killing all dropbear instances ..."

  killall -9 dropbear

  echo "starting dropbear ..."

  dropbear -A -N root -U 0 -G 0 -C bice -R /etc/dropbear/auth

  if [ $? == "0" ]; then

	echo -n "success! current ip: "

	ip -4 ad sh tiwlan0 | sed -n 's/.*inet \([0-9.]*\).*/\1/p'

  else

	echo "fail."

  fi

else

  echo "you need to be root."

fi

--- end of file ---

there's probably lots to add, but it works for me :(

now i just fire up connectbot, type "su" followed by "db" and then it's up!

get a terminal emulator (eg connectbot) and start it via a local shell. not the most comfortable way, but should work.
Link to comment
Share on other sites

thanks again!

sorry for spamming this thread, but i hate it when people just reply "oh, now it works for me!" in a thread, so i'd rather be verbose. :)

this is what i've done, and i'm pretty happy with it;

that is not spamming, that is very appreciated! looks good :(

edit: you shouldn't post your root password on the net, if it is that, and if it is that you should change it...

Edited by kendon
Link to comment
Share on other sites

Guest robin hansson

bice ~= bajs = poop (in swedish)

so, no. that's not my root pass :>

thanks for your concern though. :(

that is not spamming, that is very appreciated! looks good :)

edit: you shouldn't post your root password on the net, if it is that, and if it is that you should change it...

Link to comment
Share on other sites

Dropbear is now running at startup as of 2.7! :)

P

i haven't looked into the rom yet (gotta do a little work before :( ), but can you tell us how you did it? especially i would like to be able to change passwort & port, is it saved in some config file?

Link to comment
Share on other sites

I can externalise the port config in 2.8 too if preferred?

P

actually, i will set it once and forget about it. would be nice though to change it through ui, i would say depends on the effort to make it possible...

Nice work for dropbear, now it would be great to have a widget on/off :)

i would absolutely love that!

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.