yonamine / shellinabox

Automatically exported from code.google.com/p/shellinabox
Other
0 stars 0 forks source link

When starting shellinaboxd, I always get the erroro message "Failed to find any available port" #142

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. When running under root "shellinaboxd" I always get the erroro message 
"Failed to find any available port". What do I have to do to make sellinabox 
work?

What is the expected output? What do you see instead?
That the shellinabox demon would start

What version of the product are you using? On what operating system?
ShellInABox: shellinabox_2.10-1_amd64.deb
OS: Debian Lenny v5.0 54bit

Please provide any additional information below.

Original issue reported on code.google.com by olaf.tri...@gmail.com on 1 Oct 2011 at 2:41

GoogleCodeExporter commented 8 years ago
As far as I understand it, that way you are attempting to run SiAB without of 
the required parameters.  Try this instead:

/etc/init.d/shellinabox  start

...which will start it with the options defined in that script.  I have asked a 
question here regarding the best way to set different options, but I have never 
got an answer, so I edit that script directly.

Original comment by gomez...@gmail.com on 2 Oct 2011 at 1:23

GoogleCodeExporter commented 8 years ago
I get this error currently and its  not because of how im starting it!

Original comment by M4dH4TT3...@gmail.com on 18 Dec 2014 at 1:41

GoogleCodeExporter commented 8 years ago
This error means that some other application is already listening on port 4200.
Maybe it is even shellinabox.

You could add --port parameter so that shellinabox will run on port 4201.

./shellinaboxd --port 4201

Original comment by luka.kra...@gmail.com on 13 Mar 2015 at 2:40

GoogleCodeExporter commented 8 years ago
Hello Dears,
I am facing something similar in Raspbian.

When I perform netstat -ntl I got:

   Active Internet connections (only servers)
   Proto Recv-Q Send-Q Local Address           Foreign Address         State
   tcp        0      0 127.0.0.1:4200          0.0.0.0:*               LISTEN
   tcp        0      0 0.0.0.0:5900            0.0.0.0:*               LISTEN
   tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN
   tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
   tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN

That means that the port 4200 has been configured to shellinabox (line 1), 
right?

But when I run the command shellinabox -d:

   Failed to find any available port

If I try to change the port (shellinaboxd -p 4201), the shell stops and after a 
control Z I have repeated the netstat -ntl:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:4200          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:4201            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:5900            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN

I try to access the shellinabox in my browser, but I got a timeout.
Any idea?

Original comment by imgent...@gmail.com on 17 Mar 2015 at 1:02

GoogleCodeExporter commented 8 years ago
Hi, shellinabox is probably already running on port 4200. Try to run command 
"ps axl | grep shellinabox"
and check the output.

Output "127.0.0.1:4200" is telling us that shellinabox is configured to listen 
only on localhost, with 
option "--localhost-only". You can only connect to it from browser running on 
raspberry.

You should remove option "--localhost-only" from startup script and try again. 
I think that your startup 
script is "/etc/init.d/shellinabox". To restart shellinabox run 
"/etc/init.d/shellinabox restart".

PS: running shellinabox by hand is only usefull for testing (like "shellinaboxd 
-p 4201"), but as I can
see from your second output you should be able to connect to 
http://{IP_ADDRESS}:4201

Bye :)

Original comment by luka.kra...@gmail.com on 17 Mar 2015 at 8:23

GoogleCodeExporter commented 8 years ago
Hello luka.kra,

Thank you for your support.

The option --localhost-only was really there and I have removed it from the 
startup script. But it was not in the script, but in a config file 
(/etc/default/shellinabox) described in the script.
After restart the shellianbox I have run netstat -ntl:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:4200            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:5900            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN

Unfortunately, I could not access it in my browser. The reaction is the same:
ERR_CONNECTION_TIMED_OUT

Is there some way to check the request in the port 4200?

Here the result of "ps axl | grep shellinabox"

5   108  5552     1  20   0   4560  2400 poll_s Ss   ?          0:00 
/usr/bin/shellinaboxd -q --background=/var/run/shellinaboxd.pid -c 
/var/lib/shellinabox -p 4200 -u shellinabox -g shellinabox --user-css Black on 
White:+/etc/shellinabox/options-enabled/00+Black on White.css,White On 
Black:-/etc/shellinabox/options-enabled/00_White On Black.css;Color 
Terminal:+/etc/shellinabox/options-enabled/01+Color 
Terminal.css,Monochrome:-/etc/shellinabox/options-enabled/01_Monochrome.css 
--no-beep -s /terminal:LOGIN --disable-ssl
5   108  5553  5552  20   0   4560  1316 unix_s S    ?          0:00 
/usr/bin/shellinaboxd -q --background=/var/run/shellinaboxd.pid -c 
/var/lib/shellinabox -p 4200 -u shellinabox -g shellinabox --user-css Black on 
White:+/etc/shellinabox/options-enabled/00+Black on White.css,White On 
Black:-/etc/shellinabox/options-enabled/00_White On Black.css;Color 
Terminal:+/etc/shellinabox/options-enabled/01+Color 
Terminal.css,Monochrome:-/etc/shellinabox/options-enabled/01_Monochrome.css 
--no-beep -s /terminal:LOGIN --disable-ssl
0  1000  5613  5299  20   0   3552  1836 pipe_w S+   pts/1      0:00 grep 
--color=auto shellinabox

Original comment by imgent...@gmail.com on 19 Mar 2015 at 12:27

GoogleCodeExporter commented 8 years ago
Ok, we are making progress :)

With ps command I can see that your shellinabox starts without SSL and is 
available on "/terminal" path. You can see that by "--disable-ssl" and "-s 
/terminal..." options. That means that you should be able to access it on URL: 
http://{IP_ADDRESS}:4200/terminal

For test purposes try to run command "shellinaboxd --disable-ssl --port 4222 
--debug" and than try to connect with URL: http://{IP_ADDRESS}:4222/. You 
should see some output like this:

------------------
luka@luka-vm:~/Projects/shellinabox$ ./shellinaboxd --disable-ssl --port 4222 
--debug
Command line: ./shellinaboxd --disable-ssl --port 4222 --debug
Listening on port 4222
Accepted connection from luka-pc:63875
Handling "GET" "/"
Compressed response from 5282 to 2285
luka-pc - - [19/Mar/2015:11:22:58 +0100] "GET / HTTP/1.1" 200 2375
Handling "GET" "/styles.css"
Compressed response from 7269 to 1497
luka-pc - - [19/Mar/2015:11:22:58 +0100] "GET /styles.css HTTP/1.1" 200 1626
Accepted connection from luka-pc:63876
...
------------------

You should see this GET requests and later POST request. Note that "luka-pc" 
should be your PC name or IP address. If you don't see this you probably have 
ports 4222 (and 4200) blocked by some firewall. Do you have "iptables" or 
something alike installed and running on your system. You could try to run 
command "sudo iptables --list" ...

Maybe you could also tell us what kind of browser do you use, because there are 
some problems with IE11...

Original comment by luka.kra...@gmail.com on 19 Mar 2015 at 8:43

GoogleCodeExporter commented 8 years ago
Hello Luka,
I have followed your instructions until the iptables and it has not worked.
Then, I have researched how to open ports with iptables. I have executed the 
command:
iptables -A INPUT -p tcp --dport 4222 -j ACCEPT
After that, it has worked!!! So, the problem was the firewall
 that was blocking the ports. I can access shellinabox from a browser (Firefox and Chrome).

Thank you very much for your support. I have learned a lot.

Original comment by imgent...@gmail.com on 26 Mar 2015 at 1:55

GoogleCodeExporter commented 8 years ago
Hi, I am glad that you got it to work :)

Original comment by luka.kra...@gmail.com on 29 Apr 2015 at 8:46