csersoft / shellinabox

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

"Failed to find session" error with custom port on CentOS 6.5 #265

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Install shellinabox on CentOS 6.5 from source or Epel repository
2. Fire up the following command to connect to remote server's custom port 
19777:

***
shellinaboxd -p 4201 -c /var/lib/shellinabox --debug -s 
'/:SSH:216.xx.xxx.xx:19777'
***

3. Go to https://localhost:4201 to see command prompt with invitation to enter 
login:

***
216 login:                                                                      

***

4. However as soon as you type "root" and press "Enter" key, the debug gives on 
command line:

***
Child terminated
Handling "POST" "/?"
Failed to find session: yMjetkjDCvqWdxHsT9-iTg
c-77-103-130-53.hsd1.ca.comcast.net - - [02/Oct/2014:06:26:37 -0700] "POST /? 
HTTP/1.1" 400 458
Closing connection to c-77-103-130-53.hsd1.ca.comcast.net:52839
***

Unfortunately it doesn't accept if I try to specify the custom port otherwise:

***
shellinaboxd -p 4201 -c /var/lib/shellinabox --debug -s '/:SSH:216.xxx.xxx.xx 
-p 19777'
Invalid hostname "216.xxx.xxx.xx -p 19777" in service definition
***

However, if I fire up the same command to connect to remote server's standard 
port 22:

***
shellinaboxd -p 4203 -c /var/lib/shellinabox --debug -s '/:SSH:216.yyy.yyy.yy'
***

then it works like a charm. Unfortunately, I need to be able to SSH to remote 
servers with different than standard ports.

What is the expected output? What do you see instead?

I expected to feed "shellinaboxd" with custom port of destination server on CLI 
and not with configuration file (as configuration file allows to specify only 
one destination and I need to be able to connect to different servers changing 
ports on the fly through CLI).

What version of the product are you using? On what operating system?

I tried all of the version of shellinaboxd, unfortunately none worked. I tried 
both on CentOS and Ubuntu. I would personally CentOS if it worked.

Additional information:

I see on https://code.google.com/p/shellinabox/issues/detail?id=84 some users 
solved this issue by (1) adding:

--service=/s:user:grp:HOME:'ssh user-ssh@localhost -p 12345'

to CLI or by (2) hacking "service.c" file and disabling the hostname checking 
in it, unfortunately both methods didn't work for me. 

I really hope Shell in a box maintainers will add feature to change ports of 
destination servers on the fly through CLI and provide specific examples in 
README file.

Thank you for consideration!

Original issue reported on code.google.com by foranyc...@gmail.com on 2 Oct 2014 at 1:40

GoogleCodeExporter commented 9 years ago
By the way, I forgot to describe the outcome of the following command in CLI:

***
shellinaboxd -p 4201 -c /var/lib/shellinabox --debug 
--service=/s:shellinabox:shellinabox:HOME:'ssh root@216.xxx.xxx.xx -p 19777'
***

It gives "File Not Found" in browser window.

Original comment by foranyc...@gmail.com on 2 Oct 2014 at 1:45

GoogleCodeExporter commented 9 years ago
Yes, I don't see how the command lines that you use for SSH are going to work. 
They don't really follow any of the syntax listed in the manual page. Things 
could certainly be changed in the code, but I am not sure that's a good 
approach. There are just too many different SSH options that could legitimately 
be passed -- and we don't want a special syntax for each one of them.

On the other hand, the command line that uses the SHELL syntax should work. I 
just tried it, and it works fine for me. Maybe, you don't have "ssh" in your 
$PATH and that's why it is failing. Try giving an absolute path (e.g. 
"/usr/bin/ssh") and see if that works any better.

Having said all of the above, it might make more sense to create a suitable 
ssh_config file. Depending on how you start shellinaboxd, you might have to 
edit /etc/ssh/ssh_config or ~/.ssh/config.

You could add something like this:

  Host shellinabox
    HostName xxx
    Port xxx

Then define the service as:

  shellinaboxd -p 4201 --service=/:SSH:shellinabox

Original comment by zod...@gmail.com on 2 Oct 2014 at 6:10

GoogleCodeExporter commented 9 years ago

Original comment by zod...@gmail.com on 2 Oct 2014 at 6:10