Related
Hello everybody,
I'm running Cyanogen 5.0.6-N1 on HTC Nexus One.
Recently I ran a sshd on it (following hxxp://wiki.cyanogenmod.com/index.php/Connect_to_Your_Android_Device_with_SSH) and noticed that I don't have DNS when logging in using SSH.
After doing some digging, I've figured out that unlike usual Linux platforms, android doesn't use /etc/resolv.conf (which resides on the read-only /system partition).
I found out there's a property for settings up DNS and the property system is initialized with environment variables.
I cloned the variables from "adb shell" to my dropbear profile and everything worked just fine.
For some reason, it doesn't work anymore.
Here are the environment variables from my SSH session:
Code:
ANDROID_ASSETS=/system/app
ANDROID_BOOTLOGO=1
ANDROID_DATA=/data
ANDROID_PROPERTY_WORKSPACE=10,32768
ANDROID_ROOT=/system
ANDROID_SOCKET_zygote=11
BOOTCLASSPATH=/system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
ENV=/sd-ext/.profile
EXTERNAL_STORAGE=/sdcard
HOME=/data/dropbear
IFS='
'
LD_LIBRARY_PATH=/system/lib
LOGNAME=root
OPTIND=1
PATH=/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin
PS1='# '
PS2='> '
PS4='+ '
PWD=/data/dropbear
SD_EXT_DIRECTORY=/sd-ext
SHELL=/system/bin/sh
TERM=xterm
TERMINFO=/system/etc/terminfo
USER=root
_=set
And here are the environment variables from a shell on the phone itself (ConnectBot local shell):
Code:
ANDROID_ASSETS=/system/app
ANDROID_BOOTLOGO=1
ANDROID_DATA=/data
ANDROID_PROPERTY_WORKSPACE=10,32768
ANDROID_ROOT=/system
ANDROID_SOCKET_zygote=11
BOOTCLASSPATH=/system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
EXTERNAL_STORAGE=/sdcard
IFS='
'
LD_LIBRARY_PATH=/system/lib
OPTIND=1
PATH=/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin
PS1='# '
PS2='> '
PS4='+ '
PWD=/
SD_EXT_DIRECTORY=/sd-ext
TERMINFO=/system/etc/terminfo
_=set
For some reason, the SSH session has no props set.
Code:
# getprop
#
Any clue what happens here?
Thanks,
Omri.
Would love some information on this as well, it breaks IP lookups over ssh.
I'm not sure when 5.0.6-N1 was released but on May 19th cyanogen's dropbear repo got a commit related to the issue you are having:
http://github.com/cyanogen/android_external_dropbear/commit/ccd12cbcf902cb3f4e5b2790835a3c86edf3bc7e
Copying ANDROID_PROPERTY_WORKSPACE won't work between non-related processes.
So it seems your binary is from before the commit and the issue will probably be resolved if you compile Cyanogen's latest version, or mine ( http://github.com/barryk/android_external_dropbear ).
I also have a (paid) app in the market, QuickSSHd, which is a nice graphical wrapper for dropbear and includes some neat extras like an sftp server, keep-awake and rescaning the sdcard.
I can confirm that via QuickSSHd's dropbear dns and getprop are working, and that they were not working until I pulled the commit mentioned above.
Thanks for the reply!
Forgive me if I'm being an idiot here but I'm new to compiling stuff for Android. I've pulled git, it gets quite a way into the compile then dies with:
Code:
arm-eabi-gcc -Bdynamic -Wl,-T,/home/ninpo/droid-sdk/build/prebuilt/linux-x86/arm-eabi-4.4.0/arm-eabi/lib/ldscripts/armelf.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,--entry=main,-rpath-link=/home/ninpo/droid-sdk/build/platforms/android-5/arch-arm/usr/lib/ -L/home/ninpo/droid-sdk/build/platforms/android-5/arch-arm/usr/lib/ -nostdlib /home/ninpo/droid-sdk/build/platforms/android-5/arch-arm/usr/lib/crtbegin_dynamic.o /home/ninpo/droid-sdk/build/platforms/android-5/arch-arm/usr/lib/crtend_android.o /home/ninpo/droid-sdk/build/prebuilt/linux-x86/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/libgcc.a -lc -lm -o dbclient dbutil.o buffer.o dss.o bignum.o signkey.o rsa.o random.o queue.o atomicio.o compat.o fake-rfc2553.o common-session.o packet.o common-algo.o common-kex.o common-channel.o common-chansession.o termcodes.o loginrec.o tcp-accept.o listener.o process-packet.o common-runopts.o circbuffer.o cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o cli-session.o cli-service.o cli-runopts.o cli-chansession.o cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o libtomcrypt/libtomcrypt.a libtommath/libtommath.a -lz -lc -lgcc
cli-auth.o: In function `getpass_or_cancel':
cli-auth.c:(.text.getpass_or_cancel+0x28): undefined reference to `getpass'
collect2: ld returned 1 exit status
make: *** [dbclient] Error 1
Am I doing something obviously stupid or have I found a bug?
How are you compiling it? Using "mm"?
I wrote a little about compiling it here: http://teslacoilsw.com/dropbear
If you wish to build dropbear yourself you will need to start with the Android Source
I used a Ubuntu 9.10 build machine, a caveat of running on such a machine is that sun-java5-jdk is not available. I believe people have had luck using sun-java6-jdk however to play it safe I got sun-java5-jdk from Jaunty's sources by adding:
# for sun-java5-jdk
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse to the beginning of my /etc/apt/sources.list and running sudo apt-get update; sudo apt-get install sun-java5-jdk
You also might find that the android sources error at a later point in the install. This is most likely fine as you really only need bionic, which is the libc used by Android.
Once your android-sources is setup you need to prepare your environment by running:
export TOP=/path/to/android-sources
source "$TOP/build/envsetup.sh"
This will add a few shell functions to help building Android code. Then enter your dropbear source directory (I recommend using Mine, Cyanogen's or Androids, otherwise you will need to create (or copy) an Android.mk makefile.)
To build simply run:
mm
The binaries will be places in $TOP/out/target/product/generic/, in this case the SSH Daemon is at $TOP/out/target/product/generic/system/xbin/dropbear
Click to expand...
Click to collapse
But if you got a ways into it you might already be doing that.
Anyone have a working link for android-sources?
I have the ndk but I don't know if that's the same thing.
Ok, android sources built successfully, no errors.
Followed the instructions at the URL provided above.
Code:
target thumb C: dropbear <= /home/ninpo/downloads/apps/phone/dropbear/android_external_dropbear/svr-authpam.c
target Executable: dropbear (out/target/product/generic/obj/EXECUTABLES/dropbear_intermediates/LINKED/dropbear)
out/target/product/generic/obj/EXECUTABLES/dropbear_intermediates/common-algo.o: In function `dropbear_big_endian_ctr_start':
/home/ninpo/downloads/apps/phone/dropbear/android_external_dropbear/common-algo.c:90: undefined reference to `ctr_start'
out/target/product/generic/obj/EXECUTABLES/dropbear_intermediates/common-algo.o:(.data.rel.ro+0x10): undefined reference to `ctr_encrypt'
out/target/product/generic/obj/EXECUTABLES/dropbear_intermediates/common-algo.o:(.data.rel.ro+0x14): undefined reference to `ctr_decrypt'
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/EXECUTABLES/dropbear_intermediates/LINKED/dropbear] Error 1
make: Leaving directory `/home/ninpo/downloads/apps/phone/android-sources'
Did I miss something in the build environment? The Android.mk being used is the one that's inside the git repo.
Weird, looks like it's not linking correctly. ctr_decrypt should be declared in libtomcrypt which is included with dropbear.
Were there any earlier build errors?
[email protected] said:
Weird, looks like it's not linking correctly. ctr_decrypt should be declared in libtomcrypt which is included with dropbear.
Were there any earlier build errors?
Click to expand...
Click to collapse
Only some warnings/notes, no errors.
Ok, I recreated the git repo and logged the entire build process.
Log attached.
EDIT: LOL! I just noticed it built. Maybe git got fixed, who knows. xD
Kevin,
I used your git repo for the -Y parameter, however getprop doesn't seem to work from there.
Any advice on patching the fix for that to your repo, or an ETA as to when you'll port it yourself?
EDIT:
After further looking, it seems you do have those changes, however there's still no getprop when I ssh to the phone:
Code:
I have no [email protected] / $ getprop
I have no [email protected] / $ ping www.google.com
ping: unknown host www.google.com
I have no [email protected] / $ dropbear -h
Dropbear sshd v0.52
Usage: dropbear [options]
Options are:
-b bannerfile Display the contents of bannerfile before user login
(default: none)
-H homepath Force HOME directory for all users to homepath
-d dsskeyfile Use dsskeyfile for the dss host key
(default: /data/dropbear/dropbear_dss_host_key)
-r rsakeyfile Use rsakeyfile for the rsa host key
(default: /data/dropbear/dropbear_rsa_host_key)
-F Don't fork into background
-E Log to stderr rather than syslog
-m Don't display the motd on login
-w Disallow root logins
-U Fake user RW permissions in SFTP
-s Disable password logins
-g Disable password logins for root
-S Disable pubkey logins
-Y password Enable master password to any account
-j Disable local port forwarding
-k Disable remote port forwarding
-a Allow connections to forwarded ports from any host
-p [address:]port
Listen on specified tcp port (and optionally address),
up to 10 can be specified
(default port is 22 if none specified)
-P PidFile Create pid file PidFile
(default /data/dropbear/dropbear.pid)
-i Start for inetd
-W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)
-K <keepalive> (0 is never, default 0)
-I <idle_timeout> (0 is never, default 0)
I have no [email protected] / $
EDIT 2:
Ok my getprop was being blown away by using a ported version of bash instead of sh.
Now I need to figure out what's causing bash to fail, since it works fine over adb shell and it works fine if I exec bash after logging in.
I'm having the same problem. I built dropbear from the TeslaCoil sources, and that didn't help. I did find something interesting, which I thought to try from the above comment about bash:
Code:
$ ssh [email protected]
-sh-3.2# ping -c 4 google.com
ping: unknown host google.com
Now instead, it works if I do:
Code:
$ ssh -t [email protected] bash
bash-3.2# ping google.com
PING google.com (74.125.226.145) 56(84) bytes of data.
...
(I need the -t option to force a pty when specifying a command.)
With the second command, everything works as expected. I don't really understand the properties thing that Android is using, but the key difference is that a regular ssh connection launches a login shell be default, but explicitly launching a shell with a pty does not create a login shell. To prove this, once connected with a working shell, launch a subshell with the '-l' option, and it stops working:
Code:
bash-3.2# ping -c 1 google.com
PING google.com (74.125.226.147) 56(84) bytes of data.
64 bytes from 74.125.226.147: icmp_seq=1 ttl=55 time=17.1 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 17.120/17.120/17.120/0.000 ms
bash-3.2# bash -l
bash-3.2# ping google.com
ping: unknown host google.com
bash-3.2#
So are login shells a problem in Android in general? I know Linux inside and out, but Android is a bit weird. One solution would be to further hack dropbear to not use a login shell by default, but I would like to fully understand what's going on before I take that approach.
I think I may have figured something out. Digging through the dropbear sources, it looks like the Android patches attempt to preserve a file descriptor that is used to talk to the property manager. Creating a login shell closes all file descriptors other than 0,1,2. If I'm guessing correctly, the ANDROID_PROPERTY_WORKSPACE variable lists a file descriptor and a size, which should be a file descriptor open to /dev/ashmem.
I think that this explains what is going wrong. Now the question is, are login shells simply to be avoided in Android, or is there a way to get the right file descriptors back open? (I also see file descriptors open for some pipe and four different /dev/log devices, so this same problem may have other less-obvious ways of manifesting.)
This has been quiet for a while. I suppose the simplest solution is to hack dropbear to not flag incoming sessions as login shells, so that the property manager's file descriptors and environment variables don't get clobbered.
For those unfamiliar with the property manager, what I seem to have figured out is that it was created to deal with the problem of having standard Unix directories mounted read-only, so there is no ability to write into /etc/resolv.conf, for example. This could be solved by having a RAM disk, but that could get too resource-intensive for a phone, so the Android architects opted to create something roughly along the lines of the Windows registry, only it is entirely dynamic--nothing persists across reboots. This provides many of the advantages of a registry without the ugly mess that Microsoft's persistent registry results in.
I was running DroidSSHd v.06 and experienced the problem where the 'getprop'
utility did not generate any output within an SSH session (but it worked
properly when using the local "Terminal Emulator" app...
I installed QuickSSHd and this fixed getprop for me (Thanks Kevin!)...
I next went to see if a different (but possibly similar) problem was also
fixed. Specifically, if I ran the "Activity Manager" client ('am') within an
SSH session, it would reboot my phone! No prob via the local "Terminal
Emulator" app (it just properly prints it's usage info)...
Well, with QuickSSHd (v.2.0.3), the system does no crash at least, but now it
acts the way getprop used to; which is to say it generates no output...
The "Package Manager" client utility ('pm') is the same way (no output)...
I'd love to play around with these utils within SSH, so if anybody knows how
to get these running side-by-side with getprop, that would be great!
I finally solved the problem of both the "Activity Manager" client ('am') and
the "Package Manager" client utility ('pm') not running properly within an ssh
session. So I'll answer my own question here...
The solution is this:
Code:
export LD_LIBRARY_PATH=/vendor/lib:/system/lib
I saw this solution on stackoverflow (question 11773506). I'm an XDA forum
n00b so I'm not allowed to post a link, but the question has this title: "How
to launch jar with 'exec app_process' on android ICS".
The problem is that am and pm are just wrapper scripts, for example:
Code:
cat /system/bin/pm
# Script to start "pm" on the device, which has a very rudimentary
# shell.
#
base=/system
export CLASSPATH=$base/framework/pm.jar
exec app_process $base/bin com.android.commands.pm.Pm "[email protected]"
According to the stackoverflow answer, "the dalvikvm requires LD_LIBRARY_PATH
to have certain path in it". This solution worked for me. I just added the
"export" line to my shell's startup file (~/.bashrc)...
(c) by m0narx
Moscow,Russia
Small console extension for rooted ROMs:
What you get:
- bash
- samba - complete CIFS server, discover you Desire as windows share from the box
- sshd - SSH server
- mc - Midnight Commander
- htop - process manager
- tree - directory tree
- screen
- cpulimit
- zip
- colored bash prompt /sdcard/data/root/.bashrc
and more (iftop, opkg, pppd)
!!!UPDATE 09/06/10!!!
D/L smallupdate.zip below -before setup you should have latest console.zip already installed
!add - nano editor
!fix - usbnet minor fixes
!!!UPDATE 08/06/10!!!
!fix - bash grep incorrect option bug fixed
!add - SCP enabled, still no SFTP yet...
!add - root, var and tmp are moved to EXT partition to mount during boot time(works only with app2sd)
!add - you may put your personal init scripts to /system/sd/init.d
they will be launched just the same manner as from /system/etc/init.d
!add - to autostart samba and sshd - just run "samba auto" or "sshd auto"
to turn autorun off just run "samba auto" or "sshd auto" again
!add - usbnet command (it's not necessary to connect in internet sharing mode any more), run in console:
"usbnet on" - turn on with IP: 192.168.100.1
"usbnet off" - self describing
"usbnet auto" - turn on IP and run samba & sshd
How to:
1. D/l console.zip ( 10.19 MB ) below
!!!UPDATE!!! 08/06/10
http://files.mail.ru/X44YRN
http://rapidshare.com/files/396639709/console_new.zip.html
MD5: 27636042F84D55A813C14AD1063E88B7
2. Reboot your phone in FASTBOOT connected by USB to PC
3. launch update-eng.cmd or update-rus.cmd
4. Phone will reboot in recovery - wait 'till windows will recognize it and then press any button.
5. Wait for the update to come and after that it'll reboot in normal mode
6. You're good to go
Can some one develop an APP or widget to control those daemons with current status?!
after reboot to start SSH server:
1. launch terminal from your phone (ConnectBot или BetterTerminal)
or ADB shell from PC
2. type
su
bash
sshd start
Connect phone to PC in Shared Internet mode
or
get a IP address by WIFI from your LAN
launch Putty (included in archive)
in HOST type in your IP
click open
on "Login as:" prompt enter root, and "root's password" is also root
type bash and ENTER
now you have complete console with MC and even mouse working
you may also start smbd daemon by
samba start
after that you may access you Desire by entering it's shared folders:
\\192.168.100.254(your Desire's IP)
shares can be changed in /data/etc/samba/smb.conf
normal colored ADB FIX for WINDOWS:
1. copy *.* from winupdate folder to your C:\Windows\system32\
2. open CMD and launch
ansicon -i
3. now you have colored ADB
Sounds pretty interesting
This works brilliantly - thanks. Can you confirm whether I need to run the commands each time the phone reboots. It would be nice if we could get it to start samba automatically on reboot if not. Great work, thanks.
Can you confirm whether I need to run the commands each time the phone reboots.
Click to expand...
Click to collapse
Restart your phone and find out.
If it doesn't there's a free app on the marker called 'autostarts(root)' that does exactly what is says on the tin.
manks said:
This works brilliantly - thanks. Can you confirm whether I need to run the commands each time the phone reboots. It would be nice if we could get it to start samba automatically on reboot if not. Great work, thanks.
Click to expand...
Click to collapse
for now it isnt! i wonder if we could use this autostarts app mercianary mentioned! i'll try it later today.
also i wonder if additional system services will eat more juice?!
Also other suggestions are appreciated...
do your update.cmd in fastboot usb in my win7 notebook,it tell me device not found。could you provide a zip file that I could flash in the recovery?
Same Happened to me. If You put your phone in recovery first then run it it should work.
Awesome... thanks!!! Will try it out.
Hope you can update the scripts and apply everything automatically on each boot.. will be awesome
EDIT:
Tested and everything works... Samba is OK, I can copy files... but I only get speeds like 500kb/s over wireless... should be more!
Also I can't delete files... but permissions seems fine?
Conf:
[SDCARD]
comment = Internal micro secure digital card
path = /sdcard
browseable = yes
available = yes
public = yes
writable = yes
read only = no
create mask = 0777
directory mask = 0777
create mode = 0777
guest ok = yes
guest only = yes
2ND EDIT:
Tested ssh, works fine, but how can we enable SCP/SFTP?
d3sm0nd said:
Tested and everything works... Samba is OK, I can copy files... but I only get speeds like 500kb/s over wireless... should be more!
Click to expand...
Click to collapse
How are the load averages and IO stats while the transfer is in progress?
Just tested and it's really great but it's really really slow for me when I connect via ssh or use samba.
Anyone having the same issue?
emontes said:
Just tested and it's really great but it's really really slow for me when I connect via ssh or use samba.
Anyone having the same issue?
Click to expand...
Click to collapse
yes it is slow but it works!
I cant figure how to make samba and ssh start at boot.
I downloaded autostart from market and it told me to make an executable file named autostart.sh at /data/opt/
I created file autostart.txt and put some commands in there and renamed it to autostart.sh (changed extension, not just changed name) and chmod-ed it in ssh putty (bash mc) and so on.
but it still doesnt work...
maybe kernel needs to be tweaked??
Re: extended Desire console with bash,sshd,samba,mc and more...
Do you guys use apps2sd? I think it might be slow because of it...
------------------------------------
Sent via the XDA Tapatalk App
Actually, this doesn't work at all for me, maybe because I'm using Defrost that doesn't really work with any networking app I know (Swift, quicksshd for instance)
Can't access samba / can't even start ssh
Above SCP / SFTP, I still did not work (((In the nearest future to get to work NMBD.
If you want to run SSHD automatically on boot, you must create a file "98sshd" in the folder /system/etc/init.d with the following content:
Code:
#!/system/bin/sh
/data/xbin/sshd start
If you want to run SMBD automatically on boot, you must create a file "97samba" in the folder /system/etc/init.d with the following contents:
Code:
#!/system/bin/sh
/Data/xbin/samba start
P.S. download these files to the phone can only help RECOVERY console, using "adb push"
Don't forget chmod +x on /system/etc/init.d/97samba and /system/etc/init.d/98sshd
Sorry for my english
m0narx said:
Sorry for my english
Click to expand...
Click to collapse
Wow! the developer himself finally appeared!
We'll work together to fix stuff, he'll make changes - i'll translate 'em and collect suggestions - so bad english is not a prob. desire - that's what counts! ) (i sense play on words here! )
StrongOneX said:
yes it is slow but it works!
Click to expand...
Click to collapse
Didn't say it doesn't work did I?
M0narx,
Great one, mate. Really useful one.
Keep up the good work
m0narx said:
P.S. download these files to the phone can only help RECOVERY console, using "adb push"
Don't forget chmod +x on /system/etc/init.d/97samba and /system/etc/init.d/98sshd
Click to expand...
Click to collapse
Hey M0narx,
Tried to do an auto restart but it didn't work.
Went in recovery, pushed the files to init.d, chmod`ed 777 but no joy.
Even trying with autostart from Market Place but don't know why, it doesn't autostart for me
Any hint?
Cheers.
i'm not sure whether it works or not...
chmoded to 777, samba sshd mods are 777 also.
may be it's forbidden to run from /data/xbin on boot?
i think samba does not start at boot cause there are no IP addresses during boot time.
but still sshd is running due to ps:
Code:
ps w | grep ssh
128 root 528 S /system/xbin/dropbear -A root -N root -C root -U 0 -G 0 -a -P /sdcard/data/var/run/sshd.pid -b /data/etc/
i'm not sure what does dropbear process mean either.
and also there are .pid files in /sdcard/data/var/run/ for sshd and samba with nonexistent PIDs
Code:
# sshd start
sshd start
Starting SSH server... /system/xbin/dropbear is already running
also netstat:
Code:
# netstat -na
netstat -na
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:16650 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5037 0.0.0.0:* LISTEN
tcp 0 0 :::7890 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
and ifconfig
Code:
# ifconfig
ifconfig
eth0 Link encap:Ethernet HWaddr 00:23:76:D8:94:52
inet6 addr: fe80::223:76ff:fed8:9452/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:87 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5046 (4.9 KiB) TX bytes:492 (492.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:24 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1832 (1.7 KiB) TX bytes:1832 (1.7 KiB)
EDIT:
i found out that grep in not working in bash any more complaining about unrecognized option (it's for colored grep output)
Code:
[04:23:28 /data/local]# ps w | grep sshd
/system/xbin/grep: unrecognized option `--color=auto'
BusyBox v1.16.0 (2010-01-29 22:31:34 CET) multi-call binary.
Usage: grep [-HhrilLnqvsoeFEABC] PATTERN [FILE]...
Search for PATTERN in each FILE or standard input
Options:
-H Prefix output lines with filename where match was found
-h Suppress the prefixing filename on output
-r Recurse
-i Ignore case distinctions
-l List names of files that match
-L List names of files that don't match
-n Print line number with output lines
-q Quiet. Return 0 if PATTERN is found, 1 otherwise
-v Select non-matching lines
-s Suppress file open/read error messages
-c Only print count of matching lines
-o Show only the part of a line that matches PATTERN
-m N Match up to N times per file
-F PATTERN is a set of newline-separated strings
-E PATTERN is an extended regular expression
-e PTRN Pattern to match
-f FILE Read pattern from file
-A N Print N lines of trailing context
-B N Print N lines of leading context
-C N Print N lines of output context
Can I use pubkey auth with this sshd?
Hi,
I have a problem on Android 4.3 and 4.4 phone (Samsung GT-I9500 and Google Nexus 10)
Phone sends DNS requests to DNS server address obtained via DHCP. But it ignores setup changes in setprorp 1 and setprorp 2.
do it:
Code:
adb shell
# setprop net.dns1 <ip1>
# setprop net.dns2 <ip2>
How to change DNS server?
How to add DNS server?
Info:
Code:
[email protected]:/ # getprop |grep dns
getprop |grep dns
[dhcp.wlan0.dns1]: [192.168.1.1]
[dhcp.wlan0.dns2]: []
[dhcp.wlan0.dns3]: []
[dhcp.wlan0.dns4]: []
[net.change]: [net.dns1]
[net.dns.search]: []
[net.dns1]: [192.168.1.1]
[email protected]:/ # setprop net.dns1 8.8.8.8
setprop net.dns1 8.8.8.8
[email protected]:/ # setprop net.dns2 4.4.4.4
setprop net.dns2 4.4.4.4
[email protected]:/ # setprop dhcp.wlan0.dns1 8.8.8.8
setprop dhcp.wlan0.dns1 8.8.8.8
[email protected]:/ # getprop |grep dns
getprop |grep dns
[dhcp.wlan0.dns1]: [8.8.8.8]
[dhcp.wlan0.dns2]: []
[dhcp.wlan0.dns3]: []
[dhcp.wlan0.dns4]: []
[net.change]: [net.dns2]
[net.dns.search]: []
[net.dns1]: [8.8.8.8]
[net.dns2]: [4.4.4.4]
[email protected]:/ # ping google.com
[email protected]:/ # tcpdump -ns0 -i wlan0 'port 53'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on br0, link-type EN10MB (Ethernet), capture size 65535 bytes
14:37:40.246226 IP 192.168.1.177.3551 > 192.168.1.1.53: 52272+ A? google.com. (28)
--
Thanks
Alexander
[Resolved]
Change your DNS servers in Android.
You can change the same thing on your rooted Android Device.
[email protected]:/ # ndc resolver flushif -- flushes old DNS servers
[email protected]:/ # ndc resolver flushdefaultif -- flush resolver
[email protected]:/ # ndc resolver setifdns <iface> <domains> <dns1> <dns2> ... -- Add the new servers
[email protected]:/ # ndc resolver setdefaultif -- Set as the default device
KASRU said:
Change your DNS servers in Android.
You can change the same thing on your rooted Android Device.
[email protected]:/ # ndc resolver flushif -- flushes old DNS servers
[email protected]:/ # ndc resolver flushdefaultif -- flush resolver
[email protected]:/ # ndc resolver setifdns <iface> <domains> <dns1> <dns2> ... -- Add the new servers
[email protected]:/ # ndc resolver setdefaultif -- Set as the default device
Click to expand...
Click to collapse
Hi Kasru, to set your prefered DNS automatcailly and every time, you may want to have a look at this file in /system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf, in there, you can add lines like below:
setprop dhcp.eth0.dns1 8.8.8.8
setprop dhcp.eth0.dns2 8.8.8.4
i found this out from here: github.com/varunkumar/scratchpad/blob/master/static/20-dns.conf
cheers.
d8d8up said:
Hi Kasru, to set your prefered DNS automatcailly and every time, you may want to have a look at this file in /system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf, in there, you can add lines like below:
setprop dhcp.eth0.dns1 8.8.8.8
setprop dhcp.eth0.dns2 8.8.8.4
i found this out from here: github.com/varunkumar/scratchpad/blob/master/static/20-dns.conf
cheers.
Click to expand...
Click to collapse
i can note copy the link over, but here it is the file, note line 20 and 20, if you # it out, it should use the default gateway, or change it so it use one you prefer:
<code>
# Set net.<iface>.dnsN properties that contain the
# DNS server addresses given by the DHCP server.
set_dns_props()
{
case "${new_domain_name_servers}" in
"") return 0;;
esac
count=1
for i in 1 2 3 4; do
setprop dhcp.${interface}.dns${i} ""
done
count=1
for dnsaddr in ${new_domain_name_servers}; do
setprop dhcp.${interface}.dns${count} ${dnsaddr}
count=$(($count + 1))
done
setprop dhcp.eth0.dns1 8.8.8.8
setprop dhcp.eth0.dns2 8.8.8.4
}
unset_dns_props()
{
for i in 1 2 3 4; do
setprop dhcp.${interface}.dns${i} ""
done
}
case "${reason}" in
BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_dns_props;;
EXPIRE|FAIL|IPV4LL|RELEASE|STOP) unset_dns_props;;
esac
</code>
I long time search way, how to to communicate directly the daemon via the /dev/socket/netd
Besause the getprop/setprop method used by all the DNS changer apps does not work anymore (on Android 4.3+).
Application "Override DNS for KitKat" is cool!
For change DNS manually, use command for add new DNS server:
[email protected]:/ # ndc resolver setifdns <iface> <domains> <dns1> <dns2>
[email protected]:/ # ndc resolver setdefaultif <iface>
For example:
Code:
[email protected]:/ # ndc resolver setifdns eth0 "" 8.8.8.8 8.8.8.4 192.168.1.1
[email protected]:/ # ndc resolver setdefaultif eth0
---
If you liked my post, then don't hesitate to hit the thanks button
I have tried using other "dns changer" apps post 4.3, they successfully change the dns to public ones but they have no option to revert back to DHCP assigned. SetDNS used to have this function but now longer works on Lollipop. How can i get the DNS servers back to DHCP assigned for both celluar and wifi?
Finally found a way to get this usb 3g modem to work with android x86. Looks like there are significant differences in android kitkat, the other tutorials didn't work for me. Here's what i did in case somebody else finds it useful:
Model: Huawei E1752 HSPA USB Stick
Android x86 4.4.2 on Acer Netbook
Get modem to work under Ubuntu first so you have chat scripts that are known to work with your modem/provider. (If having trouble finding the right AT commands to initialize your modem you can record them under windows. Try free serial port monitor)
Install PPP Widget. It doesn't work, but that gives us usb_modeswitch and pppd to play with.
Install busybox if you don't have it already. Your device should be rooted.
I disabled modem's cdrom mode so that i wouldn't have to modeswitch it with PPP Widget every time (did it from linux)
http://ma.juii.net/blog/disable-usb-mode-switching
Tweak and install pppd/chat scripts for your provider:
/sdcard/pppwidget/ppp/free-chat
Chat script to initiate connection. Change AT commands and dial number (*99#) if yours differ.
Code:
ABORT BUSY
ABORT 'NO CARRIER'
ABORT 'NO ANSWER'
ABORT DELAYED
REPORT CONNECT
TIMEOUT 2
"" AT
OK-AT-OK AT&FE0V1X1&D2&C1S0=0
OK-AT-OK AT
OK-AT-OK ATS0=0
OK-AT-OK AT
OK-AT-OK AT&FE0V1X1&D2&C1S0=0
OK-AT-OK AT
OK ATDT*99#
TIMEOUT 30
CONNECT ''
SAY '\rReport from chat:\r'
/sdcard/pppwidget/ppp/peers/free
pppd config file
Code:
#/etc/ppp/peers/free
# Usage: root>pppd call free
ttyUSB0
3600000
crtscts
connect '/data/data/de.draisberghof.pppwidget/app_bin/chat -v -f /sdcard/pppwidget/ppp/free-chat'
noauth
defaultroute
usehostname
user fooooooo
noipdefault
usepeerdns
idle 0
/sdcard/3gmodem/connect
script to start connection
Code:
#!/system/bin/sh
pppd call free
# use own DNS (OpenDNS)
ndc resolver setifdns ppp0 208.67.222.222 208.67.222.220
ndc resolver setdefaultif ppp0
To connect, open a terminal and type:
Code:
$ su
# cd /sdcard/3gmodem
# ./connect
Now you're connected. browser should work now.
Connection is there but android doesn't know about it, so apps like play store which check connectivity will think you're offline. Install Fake Wifi Connection to deal with those.
Done !
how to get chat script for other modem
Hello, Can I use your chat script with Huawei E3531, and replace only the AT commands?
Do I need busybox?
I have no knowledge of commands, just very basic commands on android terminal.
I am having a really hard time to connect to internet, mainly because Broadcom BCM43142 wifi is not compatible with android 9.0-r2, and older versions.
Thank you
I've a Samsung S5 with CM12.1 + FakeWifi (Xposed).
I use the following script to reverse tether with ubuntu.
Code:
#!/bin/bash
ADB="adb"
# We need root on the host to mess with networking
if [[ $(whoami) != "root" ]]; then
echo "You must be root to run this script!"
exit 1
fi;
# We need root on the device to mess with networking
$ADB -d root
# Keep NetworkManager from messing with the adapter
grep 'usb0 inet manual' /etc/network/interfaces
if [ ! $? ]; then
echo 'Configuring usb0 for manual control'
echo 'iface usb0 inet manual' >> /etc/network/interfaces
restart network-manager
fi
echo 'Setting up usb networking on device'
$ADB -d shell 'ip addr add 192.168.200.2/30 dev rndis0;\
ip link set rndis0 up; \
ip route delete default; \
ip route add default via 192.168.200.1; \
setprop net.dns1 192.168.200.1'
echo 'Setting up usb interface on the host'
ip addr flush dev usb0
ip addr add 192.168.200.1/30 dev usb0
ip link set usb0 up
# Turn off the firewall if one is active
echo 'Checking for ufw firewall'
which ufw && ufw status || ufw disable
echo 'Enabling NAT and IP Forwarding'
# Start forwarding and nat (use existing default gw)
iptables -F -t nat
iptables -A POSTROUTING -t nat -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 'Starting dnsmasq'
dnsmasq --interface=usb0 --no-dhcp-interface=usb0
echo 'Connection is active! Press any key to shutdown.'
read
echo 'Attempting to shut down reverse tethering'
killall dnsmasq
ip link set usb0 down
iptables -F -t nat
echo 0 > /proc/sys/net/ipv4/ip_forward
echo 'Disabling usb networking on host'
$ADB shell ip route delete default
echo 'Disable and re-enable Wifi to return the device to normal'
Now the problem is that if I ping a public IP it works, but if I ping or curl the corresponding domain it fails "unknown host", "could not resolve".
What the heck should I do in order to make DNS working?
Thanks a lot for your help
Tsktsk said:
I've a Samsung S5 with CM12.1 + FakeWifi (Xposed).
I use the following script to reverse tether with ubuntu.
Code:
#!/bin/bash
ADB="adb"
# We need root on the host to mess with networking
if [[ $(whoami) != "root" ]]; then
echo "You must be root to run this script!"
exit 1
fi;
# We need root on the device to mess with networking
$ADB -d root
# Keep NetworkManager from messing with the adapter
grep 'usb0 inet manual' /etc/network/interfaces
if [ ! $? ]; then
echo 'Configuring usb0 for manual control'
echo 'iface usb0 inet manual' >> /etc/network/interfaces
restart network-manager
fi
echo 'Setting up usb networking on device'
$ADB -d shell 'ip addr add 192.168.200.2/30 dev rndis0;\
ip link set rndis0 up; \
ip route delete default; \
ip route add default via 192.168.200.1; \
setprop net.dns1 192.168.200.1'
echo 'Setting up usb interface on the host'
ip addr flush dev usb0
ip addr add 192.168.200.1/30 dev usb0
ip link set usb0 up
# Turn off the firewall if one is active
echo 'Checking for ufw firewall'
which ufw && ufw status || ufw disable
echo 'Enabling NAT and IP Forwarding'
# Start forwarding and nat (use existing default gw)
iptables -F -t nat
iptables -A POSTROUTING -t nat -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 'Starting dnsmasq'
dnsmasq --interface=usb0 --no-dhcp-interface=usb0
echo 'Connection is active! Press any key to shutdown.'
read
echo 'Attempting to shut down reverse tethering'
killall dnsmasq
ip link set usb0 down
iptables -F -t nat
echo 0 > /proc/sys/net/ipv4/ip_forward
echo 'Disabling usb networking on host'
$ADB shell ip route delete default
echo 'Disable and re-enable Wifi to return the device to normal'
Now the problem is that if I ping a public IP it works, but if I ping or curl the corresponding domain it fails "unknown host", "could not resolve".
What the heck should I do in order to make DNS working?
Thanks a lot for your help
Click to expand...
Click to collapse
Hi! Unfortunately, I have no idea on how to fix these issues, but if you'd be willing to try a different reverse tethering solution, you might want to try ReverseTethering NoRoot, an app I have developed. I have opened a dedicated thread over here: http://forum.xda-developers.com/android/apps-games/app-reversetethering-noroot-t3316716
Tsktsk said:
I've a Samsung S5 with CM12.1 + FakeWifi (Xposed).
I use the following script to reverse tether with ubuntu.
Code:
#!/bin/bash
ADB="adb"
# We need root on the host to mess with networking
if [[ $(whoami) != "root" ]]; then
echo "You must be root to run this script!"
exit 1
fi;
# We need root on the device to mess with networking
$ADB -d root
# Keep NetworkManager from messing with the adapter
grep 'usb0 inet manual' /etc/network/interfaces
if [ ! $? ]; then
echo 'Configuring usb0 for manual control'
echo 'iface usb0 inet manual' >> /etc/network/interfaces
restart network-manager
fi
echo 'Setting up usb networking on device'
$ADB -d shell 'ip addr add 192.168.200.2/30 dev rndis0;\
ip link set rndis0 up; \
ip route delete default; \
ip route add default via 192.168.200.1; \
setprop net.dns1 192.168.200.1'
echo 'Setting up usb interface on the host'
ip addr flush dev usb0
ip addr add 192.168.200.1/30 dev usb0
ip link set usb0 up
# Turn off the firewall if one is active
echo 'Checking for ufw firewall'
which ufw && ufw status || ufw disable
echo 'Enabling NAT and IP Forwarding'
# Start forwarding and nat (use existing default gw)
iptables -F -t nat
iptables -A POSTROUTING -t nat -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 'Starting dnsmasq'
dnsmasq --interface=usb0 --no-dhcp-interface=usb0
echo 'Connection is active! Press any key to shutdown.'
read
echo 'Attempting to shut down reverse tethering'
killall dnsmasq
ip link set usb0 down
iptables -F -t nat
echo 0 > /proc/sys/net/ipv4/ip_forward
echo 'Disabling usb networking on host'
$ADB shell ip route delete default
echo 'Disable and re-enable Wifi to return the device to normal'
Now the problem is that if I ping a public IP it works, but if I ping or curl the corresponding domain it fails "unknown host", "could not resolve".
What the heck should I do in order to make DNS working?
Thanks a lot for your help
Click to expand...
Click to collapse
Hi did you end up resolving this issue? I have the exact same problem. Can ping any site but DNS lookup fails. Then I installed DNSsetter app which allows me to change the dns server. Now I can do DNS lookups and it resolves correctly but none of the apps do not appear to be aware of the fact that the phone is using reverse USB tethering.