"Permission Denied" trying to ssh from terminal - Android Software/Hacking General [Developers Only]

Hey folks, having an issue trying to ssh from within the terminal app using CM5 or CM6. Not a huge issue, ConnectBot works just fine. But I was hoping to use the command line ssh program to script up a few things.
The first is that ssh doesn't appear to use DNS. No matter what domain name I give it, it errors out. So I've just been feeding it IP addresses directly instead.
Second: I can use ssh as root no problem, but not as a normal user. When running as root it complains about trying to create /.ssh on a readonly filesystem, but it completes the connection and functions. However, when trying to run as a normal user ssh just says "permission denied" and exits. I had assumed it was trying to create a .ssh and failing. I've tried setting up a directory that the user can write to under /data and setting that as HOME before running ssh, but I still get the same error.
Anyone know what the real underlying error might be here, and how to fix it? Thanks.

Related

Installing Debian on the G1

This was already mentioned by alansj here, but I though it was important enough to have it's own thread
Saurik has created a Debian image you can install onto your sd card. Once installed, you have the full power of debian on your phone. No more puny little busybox
Instructions and such are here.
Thanks Saurik!
I was actually looking into this earlier... let me know how it runs
cant download a few things
can not open ext2.ko......when i type insmod $kit/ext2.ko ...i get "insmod: can't open ' /sdcard/kit/ext2.ko'...some one please help me out
What graphical interface does this install, or is there one?
cbrunner said:
What graphical interface does this install, or is there one?
Click to expand...
Click to collapse
That was my question when I heard about this... I just went for it though because when I read through the instructions, I realized that everything is stored in the MicroSD card and in RAM (which is reset when the phone is rebooted)
It turns out that there is no GUI - just a good old text-based Debian install! I'm sure that someone will get one working... or maybe just port the entire BSD Subsystem along with apt so we can just forget the Market...
amgupt01 said:
That was my question when I heard about this... I just went for it though because when I read through the instructions, I realized that everything is stored in the MicroSD card and in RAM (which is reset when the phone is rebooted)
It turns out that there is no GUI - just a good old text-based Debian install! I'm sure that someone will get one working... or maybe just port the entire BSD Subsystem along with apt so we can just forget the Market...
Click to expand...
Click to collapse
This awesome article has answered tons of my questions and also seems to imply otherwise:
"This does not replace Android. This also gives you access to the full plethora of programs available in Debian and let's you continue using your phone as it was intended to be: as an Android device with all the capabilities thereof."​
In addition, this IRC channel is where the author of that article idles.
cbrunner said:
This awesome article has answered tons of my questions and also seems to imply otherwise:
"This does not replace Android. This also gives you access to the full plethora of programs available in Debian and let's you continue using your phone as it was intended to be: as an Android device with all the capabilities thereof."​
In addition, this IRC channel is where the author of that article idles.
Click to expand...
Click to collapse
Right. No gui, but you have a full working linux distro on your phone. You can apt-get just about any of the normal stuff.. You could probably even get a x-windows installation to working, although you would have to connect to it remotely - it would probably be "difficult" to get it to display a gui on the phone itself (although that would be sweet).
I've installed Saurik's image on my phone, it works great. Although if you do the "unionfs.sh" step, the wifi settings don't quite work right anymore. It won't let you enable or disable wifi.
But I was able to get an ssh server (with real user and password management) and even a samba server running on my phone quite easily with this . I've also got gcc installed, and will start playing around with developing directly on the phone (instead of having to cross compile).
Sorry for not being hip to the game, but what the heck is Debian?
donutman said:
Sorry for not being hip to the game, but what the heck is Debian?
Click to expand...
Click to collapse
Arguably the most influential distribution of Linux ever. Its package management system, apt, is awesome, and it is what Ubuntu and tons of other distros were started from.
Why would you not use Google before asking here?
can anyone help with my above mentioned problem
i want this baby to run
Is your phone connected to your computer? You lose access to the storage card when it is, I think (you can't cd to it when it's plugged in) and unplugging my phone allowed me to install the module.
/a
Installing Debian errors?
Here is what I get:
insmod $kit/ext2.ko
insmod: init_module '/sdcard/kit/ext2.ko' failed (Operation not permitted)
i've been through this, i'm not gonna explain what happens and why, but imo, the only way to get a real root is the following:
-Install telnet client to your device (from android market).
-Reboot your phone to be sure no telnet-daemons/shells are running.
-When you are on the desktop, just type "enter", "telnetd", "enter". (If you do it from the terminal app it will run under the uid of the terminal app which is not root).
-Then run the telnet client app, and connect to local host. (Or skip this step + the first one if you wanna connect from another pc)
I know it's weird, but when you run something from the terminal app it runs under the terminal app's uid, even if you run a new shell, you still are eg. "app_33", not root. and btw you will have to set the environment variables all from the same shell, that means you can't have a script cause it will run under another shell, with another uid. I'm so confused... maybe I'm wrong but android is not the most friendly environment.
aggtrfrad said:
i've been through this, i'm not gonna explain what happens and why, but imo, the only way to get a real root is the following:
-Install telnet client to your device (from android market).
-Reboot your phone to be sure no telnet-daemons/shells are running.
-When you are on the desktop, just type "enter", "telnetd", "enter". (If you do it from the terminal app it will run under the uid of the terminal app which is not root).
-Then run the telnet client app, and connect to local host. (Or skip this step + the first one if you wanna connect from another pc)
I know it's weird, but when you run something from the terminal app it runs under the terminal app's uid, even if you run a new shell, you still are eg. "app_33", not root. and btw you will have to set the environment variables all from the same shell, that means you can't have a script cause it will run under another shell, with another uid. I'm so confused... maybe I'm wrong but android is not the most friendly environment.
Click to expand...
Click to collapse
Haha I feel you. Now the thing is when I am at the home screen on my G1 i push "Enter" on the keyboard and then type "telnetd" and then push enter again it doesnt do anything. When I open up telnet client on my PC it wont connect with wifi on.
So I then go to Telnet client on myG1 and go to connect to "localhost:23" and it says "Error while connecting to server: localhost/127.0.0.1:23 - Connection refused" the thing is that my local host for my wifi is not 127.0.0.1:23
And when I "netstat" from inside Terminal Emulator there is no address with port "23"
ballaholyk84 said:
Haha I feel you. Now the thing is when I am at the home screen on my G1 i push "Enter" on the keyboard and then type "telnetd" and then push enter again it doesnt do anything. When I open up telnet client on my PC it wont connect with wifi on.
So I then go to Telnet client on myG1 and go to connect to "localhost:23" and it says "Error while connecting to server: localhost/127.0.0.1:23 - Connection refused" the thing is that my local host for my wifi is not 127.0.0.1:23
And when I "netstat" from inside Terminal Emulator there is no address with port "23"
Click to expand...
Click to collapse
Are you already running RC30?
SplasPood said:
Are you already running RC30?
Click to expand...
Click to collapse
Yes, I am running the Modified RC30 posted by JesusFreke
cbrunner said:
Why would you not use Google before asking here?
Click to expand...
Click to collapse
Because I wanted you to tell me baby. That is what a wife is suppose to do.
JesusFreke said:
Right. No gui, but you have a full working linux distro on your phone. You can apt-get just about any of the normal stuff.. You could probably even get a x-windows installation to working, although you would have to connect to it remotely - it would probably be "difficult" to get it to display a gui on the phone itself (although that would be sweet).
I've installed Saurik's image on my phone, it works great. Although if you do the "unionfs.sh" step, the wifi settings don't quite work right anymore. It won't let you enable or disable wifi.
But I was able to get an ssh server (with real user and password management) and even a samba server running on my phone quite easily with this . I've also got gcc installed, and will start playing around with developing directly on the phone (instead of having to cross compile).
Click to expand...
Click to collapse
What command did you use to get the SSH to install? Every time I do the one in the tut by saurik it errors and wont install all the way. I get an error after x11-common and it wont finish.
ballaholyk84 said:
So I then go to Telnet client on myG1 and go to connect to "localhost:23" and it says "Error while connecting to server: localhost/127.0.0.1:23 - Connection refused" the thing is that my local host for my wifi is not 127.0.0.1:23
Click to expand...
Click to collapse
localhost usually refers to the loopback interface which on most devices will be 127.0.0.1.
I'm getting the same thing here... I think there's something wrong with apt-get having to write to /tmp which does not exist (and is mounted read-only).

dhcpd on Android/ARM

Has anyone tried compiling dhcpd for Android/ARM? I'm working on a Wireless Router application for Android, and having the phone be a dhcp server would make PC setup really easy.
http://www.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/dhcpd/
No, but if you get it working, I'd gladly pay (for the program, not dhcp ).
Is it possible to set it up to a non-adhoc wireless access point? My WiFi card doesn't work for adhoc under Ubuntu :/.
I've been using dnsmasq, works great..
Any reason why you want to use the source from openbsd?
You can get DHCP server from here:
https://www.isc.org/downloadables/12
It's currently compiling on my phone but everything looks good so far.
I guess you could also the udhcp from the busybox project. I think it's smaller.
http://udhcp.busybox.net/
npace said:
Any reason why you want to use the source from openbsd?
You can get DHCP server from here:
https://www.isc.org/downloadables/12
It's currently compiling on my phone but everything looks good so far.
I guess you could also the udhcp from the busybox project. I think it's smaller.
http://udhcp.busybox.net/
Click to expand...
Click to collapse
Oh, awesome! I didn't realize busybox had a dhcp daemon. Linux/ARM is supported too, and it seems to be running fine. I'll make sure it's actually working now.
Bleh, dnsd isn't working properly. Might need to compile within the Android build environment. (None of the busybox networking related commands seem to work, even basic ones such as nslookup.)
Basically what I'm trying to do is have the phone be a DNS, DHCP, and gateway server, so that the PC connection setup is painless: just associate with a the phone's ad hoc network.
What's the busybox's default pass? Mine seems to have it, but I can't figure it out.
Koush said:
Bleh, dnsd isn't working properly. Might need to compile within the Android build environment. (None of the busybox networking related commands seem to work, even basic ones such as nslookup.)
Basically what I'm trying to do is have the phone be a DNS, DHCP, and gateway server, so that the PC connection setup is painless: just associate with a the phone's ad hoc network.
Click to expand...
Click to collapse
did you try the udhcpd applet in busybox?
JesusFreke said:
did you try the udhcpd applet in busybox?
Click to expand...
Click to collapse
Nah, failed with a bunch of errors and I didn't bother looking into it further:
Code:
busybox udhcpd -f
udhcpd: /etc/udhcpd.conf: No such file or directory
udhcpd (v1.12.2) started
udhcpd: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
udhcpd: is interface eth0 up and configured?: No such device
The missing files ones are obviously fixable, but the last one about the eth0 I have no idea about.
Koush said:
Bleh, dnsd isn't working properly. Might need to compile within the Android build environment. (None of the busybox networking related commands seem to work, even basic ones such as nslookup.)
Basically what I'm trying to do is have the phone be a DNS, DHCP, and gateway server, so that the PC connection setup is painless: just associate with a the phone's ad hoc network.
Click to expand...
Click to collapse
I'm a little confused about what you're trying to do here. In page 5 of the iptables thread, alansj has a script that will setup the wifi connection, forward the traffic using iptables and enable dnsmasq to serve as a DHCP server. (rale00 also deserves credit for building dnsmasq and the original script)
If I'm missing something here, what is it that you want to do differently?
Koush said:
Nah, failed with a bunch of errors and I didn't bother looking into it further:
Code:
busybox udhcpd -f
udhcpd: /etc/udhcpd.conf: No such file or directory
udhcpd (v1.12.2) started
udhcpd: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
udhcpd: is interface eth0 up and configured?: No such device
The missing files ones are obviously fixable, but the last one about the eth0 I have no idea about.
Click to expand...
Click to collapse
You need a udhcp.conf file like this one:
http://udhcp.busybox.net/udhcpd.conf
Then you'll need to change the interface from eth0 to whatever the wifi one is... do 'ifconfig' with your wifi on and you'll see the interface name.

ssh issues

I have a freebsd server on my home network that i used to be able to ssh into from my G1 using connectbot, but this recently stopped working. using the command line ssh program i get the following warning:
"Reading the random source seems to have been blocked. If you are experiencing problems, you probably need to find a better entropy source."
one thing i cam across while researching this was to replace /dev/random with a sym link to /dev/urandom, but i definitely want to ask an expert before i go messing around with device files.
i'm currently running JF1.42 RC33. I'm also a fairly experienced linux user, but by no means an expert. Thanks so much in advance for all your help, xda rocks!
note (for all you note lovers ): i think this stopped working when i upgraded to JF1.41 RC33, but I have no idea if that has anything to do with it. I also reinstalled freebsd around that time.
I'm using JF1.41 RC33 and have no trouble using connectbot or command line ssh. Are you able to ssh to your bsd server from something other than your G1?
yup, i'm able to do it from my main box. i'm having some trouble gettin rsa keys set up, but ssh itself is working
I updated to 1.42 and was not able to duplicate the error. Here is how those devices look on my phone:
$ ls -la /dev/*random
crw-rw-rw- 1 0 0 1, 8 Feb 12 22:30 /dev/random
crw-rw-rw- 1 0 0 1, 9 Feb 12 22:30 /dev/urandom
my devices and permissions are the same (damn lol). do you think that renaming /dev/random and making /dev/random a symbolic link to /dev/urandom would cause any problems? i'm gonna do some more research on the differences between the two, but any input would most definitely be appreciated
I'm not familiar enough with how Android as a whole works to say if that change would be ok. My concern would be about something else affected by this change.
Because of that, I would think the choice would be better made on an application level. Maybe this is an option that the connectbot developers would be willing to add as a program setting?
Perhaps there is a workaround. Some of the information out there suggests that if the random source is software-only, running more applications which access the network may cause it to unblock. After getting the error, I'd try pulling up a web page, signing into IM, searching in maps, etc. and then trying ssh. While not really a solution, if it works it would confirm the above information.
Well, I did some web browsing, messaging, and maps work, as well as installing Debian from the easy install thread, and it half worked: the terminal ssh program now works, but connectbot still doesn't. i tried 'use any unlocked key' and 'don't use keys', to no avail.
all i'm getting is a quick flash with a WARNING message that pops off the screen to fast for me to read. I think it's a different issue for connectbot? i wish i could hold onto that connectbot screen before it kicks me off...

TELNET Client

Hello...
I know some telnet client software but every command i send must be run from textbox. it's hard to run simple vi editor inside. since i want to edit some file inside it..
in better terminal emulator pro, i can run any linux command, but i cannot telnet to any host. it always said bad address even my internet connections is good.
why telnet command cannot communicate to outside connection ?
hendry said:
Hello...
I know some telnet client software but every command i send must be run from textbox. it's hard to run simple vi editor inside. since i want to edit some file inside it..
in better terminal emulator pro, i can run any linux command, but i cannot telnet to any host. it always said bad address even my internet connections is good.
why telnet command cannot communicate to outside connection ?
Click to expand...
Click to collapse
NOBODY uses telnet anymore except for local lan connections to a router or such..
I think you mean ssh.
Actually, people use telnet for testing email servers and http.
telnet google.com 80
this command is just saying "bad address" for everything.
Does someon have an answer 7 years later almost?

[Q] Debian chroot on phone/networking issue

Hello XDA Developers, I have a Debian subsystem of sorts on my phone which is created by an application called Lil' Debi. For those of you unfamiliar with it, it essentially creates a Debian install on an .iso that can be mounted onto the disk. Once mounted, a user can access a shell to interact with this Debian subsystem by running /debian/shell as root, which will chroot to its own directory system separate system accessible from the Android Terminal.
Within this Debian subsystem I have created a non-root user account for the purpose of running a few networking applications that if compromised for some reason, won't give the attacker root privileges to break everything on my phone. There's only one small problem with this setup: I can't access the internet from a non-root account.
Both my terminal emulator and Lil' Debi have full network access, even when not run as root. I am curious then, why a non-root user account should have an incapability of accessing the network. A sample of wget on my phone using Google's IP address (I use the IP address because it cannot do DNS lookup obviously) gives a Permission Denied error. At the current moment I am not sure whether this problem lies with Android or with Debian. Does the user need to be explicitly granted permissions to use the network through Debian, or is the application somehow only able to access the network if it's root?
Additional information: The ROM used is PAC ROM, so you can assume any settings changes that could be made from Cyanogenmod or Paranoid Android can be made if necessary. The phone itself is a Oneplus One. No I don't have invites, so don't bother asking.
Opinions on the matter?
Also, on an unrelated note, g++ will only run under root. If I launch it as a non-root user, it will tell me that execvp failed because cc1plus doesn't exist. Why?
Thread's fallen onto the third page, so I'm going to bump.
One day has passed, and no help offered. Bump again.
Another bump. I thought XDA was supposed to be the most knowledgeable forum on Android.
Daily bump until this problem is solved...
Still bumping...
I hope people aren't just looking at the number of replies and assuming it's resolved...
Bumping again. At least 100 people have seen this thread, and not a single one has anything to say.
Bump again. It's now been a week since I asked this question.
Bump.

Categories

Resources