yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] Bieh:
For anyone who's still struggling with it, I got it working. All I did was add:

to the end of /system/init.rc. This calls my rundropbear script which is simply:

And now I can log in with paul@phone, with password and sshkey auth :)
[G1 Android Development] professordes:
Good idea :) - what I see on the phone after starting dropbear from

an adb shell over usb is:

password auth succeeded for 'justme' from 192.168.2.10:5624

and what I see on the machine trying to login is now:

exit after auth (justme): couldn't	change user as non-root

Connection to 192.168.2.31 closed.

I get a similar message if I set dropbear running for root

exit after auth (root): couldn't	change user as non-root

Connection to 192.168.2.31 closed.

do I need to do some tinkering with passwd and group?
[G1 Android Development] seaweeduk:
Hi all, I have recently had some problems trying to configure the dropbear ssh server under cyanogen 4.0.2

I had previously managed to setup a working version of this program by using some files attached earlier in this thread and starting dropbear with a specific username and password defined.

I was excited to see dropbear added in cyanogen 4.0.2 because this had been confusing to setup as the links in this thread no longer worked and I hadn't yet found a way to make the server run at startup. However since upgrading I have been unable to get the version of dropbear included with cyanogen 4.0.2 to allow me to login.

I understand that this version of the server does not contain the ability to define a username and password and am unsure as to how I need to login. I have managed to get the server running on my phone (after generating rsa and dss keys using dropbearkey and putting them in /data/dropbear/) however I cannot find a way to define the username and password so have been unable to login to my phone via ssh.

I was hoping someone could point me in the right direction as a working ssh server on my phone would be a major advantage to myself and no doubt many others.
[G1 Android Development] seaweeduk:
After some reading it seems I may not need a password to login to ssh but instead can use keys

I have generated rsa and dsa keys as mentioned earlier however everything I have managed to read with regards to linux and using keys involves generating a "private" and "public" key??. I do not have the ability to do this on my g1 as far as I know.

Do I just need to use the rsa key I have already generated on my phone to login, if so how?
[G1 Android Development] professordes:
I tried the modaco custom ROM

http://android.modaco.com/content/h...018/26-08-1-1-modaco-custom-hero-rom-is-here/

for the Hero and dropbear works fine for me with this.
[G1 Android Development] seaweeduk:
If anyone is still having troubles please see the following

http://code.google.com/p/cyanogenmo...Priority Version Owner Summary Stars Modified

thanks to everyone who helped
[G1 Android Development] seaweeduk:
Has anyone gotten scp to work? I receive the following error
[G1 Android Development] oma:
scp works just fine for me (in server mode, for copying stuff to/from my phone). What exactly was the command that failed?
[G1 Android Development] seaweeduk:
I was trying to copy a file from my server to my phone the command was

scp somefile root@phoneip:/sdcard

it prompts me for the password logs in then the error is shown :(
[G1 Android Development] Proxin:
Very interesting. I will keep an eye on this, thanks :)
[G1 Android Development] oma:
Can you run dropbear with -F -E and post the output?
[G1 Android Development] djungelmums:
link to dropbear-files seems down :(
[G1 Android Development] farmatito:
To make dropbear work on cyanogen 4.0.4 with root password you need to:

1) Compile dropbear (statically linked with uClibc: this is needed because the native dropbear binary included in CyanogenMod 4.0.4

seems not to support correctly password protected logins, in the sense that you can login even when providing a wrong password!!!)

2) Copy the new dropbear binary to the phone

adb push dropbear /sdcard/dropbear
adb push dropbearkey /sdcard/dropbearkey

$ su
# mkdir /data/local/bin
# cp /sdcard/dropbear /data/local/bin/dropbear
# cp /sdcard/dropbear /data/local/bin/dropbearkey
# chmod 755 /data/local/bin/dropbear
# chmod 755 /data/local/bin/dropbearkey
# chown root.root /data/local/bin/dropbear
# chown root.root /data/local/bin/dropbearkey
# busybox mount -o remount,rw /dev/block/mtdblock3 /system
# echo "root:x:0:0::/:/system/bin/sh" > /etc/passwd
# echo "root::14531:0:99999:7:::" > /etc/shadow
# echo "root:x:0:" > /etc/group
# echo "root:!::" > /etc/gshadow
# echo "/system/bin/sh" > /etc/shells
# echo "PATH=\"/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin\"" > /etc/profile
# echo "export PATH" >> /etc/profile
# busybox passwd
Changing password for root
New password:
Bad password: too weak
Retype password:
Password for root changed by root
# mkdir /data/dropbear
# /data/local/bin/dropbearkey -t rsa -f /data/dropbear/dropbear_rsa_host_key
# /data/local/bin/dropbearkey -t dss -f /data/dropbear/dropbear_dss_host_key
# ln -s /data/dropbear /system/etc/dropbear
# busybox mount -o remount,ro /dev/block/mtdblock3 /system

Then as root to run your own compiled version call it with the full path:

/data/local/bin/dropbear

or add this line to your userinit.sh if you want to run it always.

Finally you can log in over wifi (or maybe over the internet):

debian:~$ ssh root@xxx.xxx.xxx.xxx
root@xxx.xxx.xxx.xxx's password:
/data/dropbear #

To test that everything is setup correctly try to login with a wrong password to see if your attempt is correctly denied:

ssh root@xxx.xxx.xxx.xxx
root@xxx.xxx.xxx.xxx's password:
Permission denied, please try again.

Enjoy
[G1 Android Development] thknave:
I'm trying all this on my MT3G with Cyanogen 4.2.3, and all was going fine until i try changing the password with "busybox passwd", to which i get the following error...

passwd: applet not found

I'm not even sure how to proceed from here, any ideas?
[G1 Android Development] pentace:
If you are confused you dont need this. :-)

Google ssh client.
[G1 Android Development] farmatito:
Yes you need a version of busybox with password management built in

as the one attached. Put it somewhere on your phone.

adb push busybox.bin /data/local/bin/busybox
adb shell
chown root.root /data/local/bin/busybox
chmod 4755 /data/local/bin/busybox

and call it as

/data/local/bin/busybox passwd
[G1 Android Development] AC!D:
hm, i hope the new busybox and dropbear get their ways into the next cyanogen release...
[G1 Android Development] geertsky:
passwd

If you're able to build all you want... why not compile passwd?

Or maybe copy a passwd file from your work station...

Anyway's... lots of Z's from me!!!

Thanks a million!!! Nice work!
[G1 Android Development] glitchsys:
You have to create a ssh key, I found this:

http://wiki.cyanogenmod.com/index.php/Connect_to_Your_Android_Device_with_SSH
[G1 Android Development] spektro:
Yay, thanks a lot, this one works nice.

One thing that maybe isn´t clear at first is that you need to generate the rsa.secret file using this:

dropbearkey -t rsa -f /data/local/rsa/rsa.secret

and so you start the daemon with any password, lets say, "alpine" with this:

dropbear -A -N root -U 0 -G 0 -C alpine -r /data/local/rsa/rsa.secret -p 0.0.0.0:22

But manually issue that command everytime you boot your device is a pain. Any hint about how to make it start automatically? Sorry for this question, but i´m new to this. Comming from "unofficial" iPhone dev scene... Thanks
[G1 Android Development] Firerat:
you can make life a little easier

echo "dropbear -A -N root -U 0 -G 0 -C alpine -r /data/local/rsa/rsa.secret -p 0.0.0.0:22" >> /sdcard/startdropbear.sh

now all you have to do is

sh /sdcard/startdropbear.sh

normally I would say put in init.d , but this ROM ( Cannon complete ) doesn't seem to have one !

grrr, already had to fix busybox links, now I may have to look deeper...

but have a read of files found in /system/etc/init.d

they may give you some clue as to where you can put things for auto run ;~) ,

often a file called userinit.conf in either /system/sd/ or /data/ can't quite remember, init.d files, if well commented will help

Edit :

you can also put the startdropbear.sh in /system/bin

and make it executable, so you can just type startdropbear.sh

busybox mount -o rw,remount /system
cp /sdcard/startdropbear.sh /system/bin/
chmod 4755 /system/bin/startdropbear.sh
busybox mount -o ro,remount /system

but keep it handy on SD for when you switch ROMs
[G1 Android Development] spektro:
Hi Firehat

Thanks for the heads up on this. I actually took some time researching before posting this.

I actually have a nexus one here, and searched the entire filesystem for a place or file to be edited in order to have this command running automatically on boot or something.

Still no luck here, since this seems to be a tiny linux thing running, and a lot of things were left out. So there´s no init.d, or system/etc/init.d or anything i could find that seems closer to it.

Also did a .sh and gave it the execute permission for any user, also setting it´s group and ownership the same as some scripts i found in the filesystem, and placed this script into the same directories the other scripts are placed, but still no go about having it being auto executed.
[G1 Android Development] ttabbal:
Ask the developer of the ROM you are using. Many of them include a provision to run a userinit.sh or there is some other way to add things to the startup. Most donut ROMs seem to look for /system/sd/userinit.sh. OpenEclair has this as well, and has the init.d directory. It is ROM specific though. Personally, I just use GScript and enable SSHd when I want it. I don't want it running all the time.
[G1 Android Development] spektro:
Thanks for the clarification. I noticed there´s a file called init.rc, which is used by init binary, right after the kernel boot process. This rc file has a bunch of commands to be issued. So, i pulled it from the phone, added the line i want, mounted the filesystem with rw permission and put the modified rc file back, but after a reboot, the init.rc file gets overwritten and everything goes back to how it was before the mod i did. Well, i guess i´ll have to live with this .sh i did and start it manually whenever i need through a terminal window.
[G1 Android Development] gloomyboy:
error after connecting

Hi I am using the files from this thread and the general information to run it on a DSTL1 with a donut rom.

dropbear starts ok with

if [ ! -d /etc/dropbear/ ]
then
/system/bin/mkdir /etc/dropbear/
fi
if [ ! -f /etc/dropbear/dropbear_rsa_host_key ]
then
/system/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
fi
if [ ! -f /etc/dropbear/dropbear_dss_host_key ]
then
/system/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
fi
/system/bin/logwrapper /system/bin/dropbear -A -N root -U 0 -G 0 -C cocacola &

The trouble is when I connect with an ssh client, I authenticate and receive:

sh: can't access tty; job control turned off

Then I am able to enter cd and pwd

but no other commands work including ls (so it is not a usable shell like this)

Could somebody point me in the right direction regarding what needs to be in place for the shell to work properly?
[G1 Android Development] IronWolve:
So this is over wifi right? If its on the telco, its most likely nat'ed IP.
[G1 Android Development] gloomyboy:
It is over wifi. I ssh to the local wifi ip on port 22, get prompted for username and password, and then comes the error and the fact I have only cd and pwd but no other commands
[G1 Android Development] Proxin:
You make the dropbear directory in /system/etc, right?

Won't it be deleted the next time you update your ROM then? As far as I know, Cyanogenmod at least, formats /system upon every update.

Also, has there been any news with finding a password yet?
[G1 Android Development] gloomyboy:
the password is no problem, you supply it on the line that launches dropbear
[G1 Android Development] Proxin:
Ah, good.

Trying this now. :)
[G1 Android Development] Proxin:
Can someone tell me how to figure out what IP my phone is using?

I have dropbear running, I think, but I can't really tell; I'm not sure the IP I try to connect to is the right one.

If I type:

# ifconfig

...then I get a few IP addresses to try.

I go to my computer and try to connect to them using WinSCP, but the closest thing I get to a connection is:

"Cannot initialize SFTP protocol. Is the host running a SFTP server?"

I tried connecting through PuTTY. It works, I think. I've managed to execute three commands:

su

bash

cd

That's it.

ls doesn't work, which leaves me pretty lost and useless.

Can someone point me to a solution to these issues?

Edit:

I think the error in WinSCP is that I was trying to use SFTP.

I changed it to try to access via SCP, but it comes up with the error that it can't use the command ls.

So my problem is still not being able to ls, or do any commands really.

What can I do to solve this?
[G1 Android Development] prscott1:
To find out which IP:

you can do "netcfg" to see which network interfaces are configured and UP;

you can do "ip route" to see the default gateway.

If you can't use ls (your $PATH is messed up for the dropbear daemon). AFter connecting do "echo $PATH" and compare it to "echo $PATH" when you are connected via local terminal or adb.

You probably need to create a .profile in the dropbear directory (in this example, mine is in /data/dropbear):

# echo "PATH=\"/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin\"" > /etc/profile

# echo "export PATH" >> /etc/profile

# echo "alias ll='ls -lart'" >> /etc/profile

HTH.

Edit: I had wrong profile directory - if you do the above, then when you ssh in, the profile is active. I also added an example of setting up an alias if you want.
[G1 Android Development] Firerat:
ifconfig, or

getprop|grep net

as for commands, it chould be a shell PATH thing

try 'export' and see what your path is

or just do

export PATH=$PATH:/system/bin:/system/xbin

PuTTY is a windows thing yes?

see if it can be configured to automatically set env variables like the PATH above
[G1 Android Development] Proxin:
Thanks for the help guys,

I think my problem was fixed by Cyanogen when he updated it to 4.2.15.

I now have a gScript shortcut to run dropbear and then display my network config (so I know what IP to connect to). I run WinSCP on my PC and it works perfectly. :)
[G1 Android Development] prscott1:
Cool!

(if you want it to start up when you reboot - you can add lines to your userinit.sh).
[G1 Android Development] Proxin:
I would do that, but I don't know how intense the background activity would be if I had dropbear automatically start a ssh daemon whenever the phone is up.

Would it eat resources unnecessarily? Or is it something that's not too bad to have running in the background?
[G1 Android Development] paulsmith288:
cannot find sshd

Hi ,

I cannot seem to locate the SSHD files at:

staulkor.com

Any other sources?
[G1 Android Development] rks752:
I've been following this thread with great interest and I've almost setup a working environment but unfortunately I've stumbled upon some errors I can't solve.

I am running a rooted HTC Hero (Android v.1.5., orig. ROM 2.73.405.5), busybox in /system/xbin/ (and a few files under /system/xbin/bb)

So, I have successfully added dropbear and dropbearkey + created DSS/RSA keys.

# dropbear -A -N root -U0 -G0 -C pwd -R ./dropbear_rsa_host_key -p 2222 -E -F

This is what I get upon connection:

[1133] Apr 22 16:25:11 Child connection from 192.168.2.131:51416

[1133] Apr 22 16:25:12 password auth succeeded for 'root' from 192.168.2.131:51416

[1133] Apr 22 16:25:12 exit after auth (root): chown(/dev/pts/6, 0, 0) failed: Operation not permitted

Permissions: devpts /dev/pts devpts rw,mode=600 0 0

(I even tried with mode=777)

Furthermore, /dev/pts contains locators 1-5 but not 6 -- I am guessing that dropbear wish to create 6?

Please help, I'm at loss here.
[G1 Android Development] farmatito:
Is your dropbear binary setuid root?

chown root.root path_to_dropbear
chmod 4755 path_to_dropbear
[G1 Android Development] rks752:
Ack, I had missed that. However:

This is what I get on the client-side now:

root@192.168.2.101's password:

[1472] Apr 22 16:55:36 exit after auth (root): couldn't change user as non-root

Dropbear on server hangs and client connection hangs too.

Hmm, when I created /etc/passwd with a root entry the actions didn't hang, instead dropping out after "exit after auth (root)". Am I onto something?
[G1 Android Development] zgornz:
deleted
[G1 Android Development] rks752:
Thanks for your help!

I contacted Kevin behind the QuickSSHd project and learned some pretty interesting things I figured I'd share with you.

First of all, my "permission denied" issues, though being root, was some environmental issue I have yet to find the source of, but the following program (Kevin) solves it:

#include <unistd.h>
main() {
seteuid(0);
setegid(0);
setgid(0);
setuid(0);
execl("/system/bin/sh", "sh", NULL);
}

so...

$ su
su
# whoami
whoami
whoami: unknown uid 2000
# setuid0
setuid0
# whoami
whoami
root

Obviously solves that so I can now ifconfig and go about my business as I please.

Furthermore, I had to receive a modified dropbear in order not to hang the client/server-programs:

$ ssh root@192.168.2.103
QuickSSHD for Android
root@192.168.2.103's password:
[1615] Apr 23 21:10:55 exit after auth (root): couldn't change user as non-root

Normally I would be stuck there but not anymore. Most likely I do not need a modified dropbear now that I have setuid0.

Does anyone of you guys know if this is related specifically to HTC's Android implementation, or Android in overall?

Thanks for all your help
[G1 Android Development] Proxin:
Having some trouble with this now... I am on the latest CM5 test, and switched from the included dropbear to the one linked here. Now for some reason I can't get it to work... my dropbear startup script does the following:

dropbear -A -N root -U 0 -G 0 -C password -r /system/etc/dropbear/dropbear_rsa_host_key -p 2222
dropbear -A -N root -U 0 -G 0 -C password -r /system/etc/dropbear/dropbear_dss_host_key -p 2222

And I get nothing listening on the correct port (0.0.0.0:2222) when I finish:

# netstat

netstat

Proto Recv-Q Send-Q Local Address Foreign Address State

tcp 0 0 127.0.0.1:5037 0.0.0.0:* LISTEN

udp 0 0 0.0.0.0:9000 0.0.0.0:*

What am I doing wrong? And is it fixable?
[G1 Android Development] rks752:
Hmm, which included?

I use the following for the one included in QuickSSHd (dropbear version 0.52), and one before that... Which I can't remember where I got it from, sorry.

# dropbear -p 38000 -H /data -Y testpasswordpleasechange123 -S -r /system/dropbear/dropbear.rsa -d /system/dropbear/dropbear.dss -P /system/dropbear/dropbear.pid -E -b /system/dropbear/banner.root 2> /data/dropbear.log

(make sure that -H <path> contains the file .profile)
[G1 Android Development] Proxin:
There is a dropbear included in CM5 that doesn't properly allow username/password. I am using the dropbear included in a post in this thread a few pages back...

I don't know if I want to have an actual app running for SSH, which is why I would prefer to stay with command-line scripts... to save resources.
[G1 Android Development] rks752:
Yes I understand that, and it's the method I was using before turning to the GUI (for design reasons).

This is the one my example was for: http://github.com/barryk/android_external_dropbear
[G1 Android Development] Proxin:
I'm confused when I go to that site, haha. I'll just try the GUI version you suggested.
[G1 Android Development] rks752:
The idea is that you compile it. :) I noticed he didn't release the binaries.
[G1 Android Development] Proxin:
That's my problem as well. I don't know how to compile, haha
[G1 Android Development] akzouu:
I am stucked

I am stucked, when i try to type: mount -o remount,rw /dev/block/mtdblock3 /system, it says permission denied
[G1 Android Development] HaloTechnology:
you should type before it

SU

to make permission
[G1 Android Development] rks752:
Are you root?

su

then command.
[G1 Android Development] Umeaboy:
May I ask you, staulkor why you haven't used http://www.openwall.com/john/ to find root-password?

Ooooops.

Did I do thaaaaat?
[G1 Android Development] Firerat:
errm, the generated password is loooong, and 'random'

the 'password' cracker you posted is only for weak passwords

its for script kiddies
[G1 Android Development] mcwire:
I'm new here so sorry for just jumping in.. I'm not even sure how old this thread is. Just wanted to say that last time I checked ssh by default won't allow root to remotely login. By default it also may refuse access to accts without passwords set. Try adding a new user and su'ing.
[G1 Android Development] kevdog:
Where are the binaries? The links to dropbear on the first post are dead --- 404.
[G1 Android Development] catzilla:
I second this. I would really love to install it.
[G1 Android Development] umaro:
Binaries

Hey guys,

This thread hasn't had any activity since last month, but since no one else posted them, I thought I should put some dropbear binaries up for people to use.

I did not compile these, instead I shamelessly extracted them from someone else's rom. They look to be compiled without any changes, so it's probably cool, but if he contacts me, i'll pull them.

I don't know how to put them into an update.zip for flashing, so you'll have to copy them to your phone manually. I REPEAT, YOU CANNOT FLASH THE ATTACHED ZIP, AND HAVE TO EXTRACT IT AND COPY THE FILES OVER MANUALLY. I've included instructions below.

If you push the 95dropbear file, it will start on boot. I have not noticed any battery loss associated with leaving dropbear running, waiting for connections.

Login as root, pw is password. you can change the password by editing the 95dropbear file (replace -Y with -C if you want to use a cleartext password)

Terminal Emulator:

mount -o remount,rw /system
cp /sdcard/dropbear /system/bin/dropbear
cp /sdcard/dropbearkey /system/bin/dropbearkey
cp /sdcard/95dropbear /system/etc/init.d/95dropbear
chmod 755 /system/bin/dropbear /system/bin/dropbearkey /system/etc/init.d/95dropbear

ADB:

adb remount
adb push dropbear /system/bin/dropbear
adb push dropbearkey /system/bin/dropbearkey
adb push 95dropbear /system/etc/init.d/95dropbear
adb shell chmod 755 /system/bin/dropbear /system/bin/dropbearkey /system/etc/init.d/95dropbear
[G1 Android Development] eitama:
Yo,

Thanks for the binaries, anyone used this so far?
[G1 Android Development] mad-murdock:
hey, i did like you mentioned. i run leedroid 2.2a on a htc desire. i can remount /system, but trying to write something to it, i just get errors.

adb:

D:\android-sdk-windows\tools>adb push dropbear /system/bin/dropbear
failed to copy 'dropbear' to '/system/bin/dropbear': Out of memory

cp via shell:

bash-3.2# cp dropb* /system/bin
cp: can't create '/system/bin/dropbear': Cannot allocate memory
cp: can't create '/system/bin/dropbearkey': Cannot allocate memory

df command:

bash-3.2# df -h /system
df -h /system
Filesystem Size Used Available Use% Mounted on
/dev/block/mtdblock3 250.0M 237.2M 12.8M 95% /system

mount tells me, its rw mounted. so there should be 12MB space - since i am new to android (but not to linux/embedded linux), some advice would be great. i wanna sftp and ssh into my device

edit: binary doesnt work on htc desire (leedroid 2.2a)

i made my own .zip which i installed via recovery. dropbear starts, accepts connections, but when i log in (after password), the process segfaults. i wonder, if it doesnt find the shell to start - hard to debug, since i have to use recovery for every change i do
[G1 Android Development] aj8600:
on the ADB part are we supposed to do it in the terminal emu?

EDIT: never mind im a fool. i figured it out