avineshwar / shellinabox

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

Session closed too fast #88

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. previous version work for listening from URL command
2. Session closed to fast
3.

What is the expected output? What do you see instead?
/usr/local/bin/shellinaboxd -d --port=4211 -t -s "/:$(id -u):$(id 
-g):HOME:"'/bin/bash -c "u=${url}; exec /usr/sbin/command listen 
\"\${u##*\\?}\""'
Loaded PAM suppport
Command line: /usr/local/bin/shellinaboxd -d --port=4211 -t -s 
/:0:0:HOME:/bin/bash -c "u=${url}; exec /usr/sbin/command listen 
\"\${u##*\\?}\""
Substituting "nobody's" primary group for "nogroup"
Listening on port 4211
Substituting "nobody's" primary group for "nogroup"
Accepted connection from 192.168.1.105:38663
Handling "GET" "//?stream"
Compressed response from 4884 to 2100
192.168.1.105 - - [27/Aug/2010:18:24:53 +0800] "GET //?stream HTTP/1.1" 200 2193
Accepted connection from 192.168.1.105:38664
Accepted connection from 192.168.1.105:38665
Handling "GET" "//styles.css"
Compressed response from 4935 to 1003
192.168.1.105 - - [27/Aug/2010:18:24:54 +0800] "GET //styles.css HTTP/1.1" 200 
1135
Handling "GET" "//ShellInABox.js"
Compressed response from 164773 to 37588
192.168.1.105 - - [27/Aug/2010:18:24:54 +0800] "GET //ShellInABox.js HTTP/1.1" 
200 37703
Accepted connection from 192.168.1.105:38666
Handling "POST" "//?"
Creating a new session: oJKOOL5nOVajeCKY-jriuw
Window size changed to 126x30
192.168.1.105 - - [27/Aug/2010:18:24:57 +0800] "POST //? HTTP/1.1" 200 157
Child terminated
Accepted connection from 192.168.1.105:38667
Handling "GET" "//favicon.ico"
Compressed response from 2307 to 1983
192.168.1.105 - - [27/Aug/2010:18:24:58 +0800] "GET //favicon.ico HTTP/1.1" 200 
2079
Accepted connection from 192.168.1.105:38668
Handling "GET" "//beep.wav"
192.168.1.105 - - [27/Aug/2010:18:24:59 +0800] "GET //beep.wav HTTP/1.1" 200 911
Accepted connection from 192.168.1.105:38670
Handling "GET" "//beep.wav"
192.168.1.105 - - [27/Aug/2010:18:25:02 +0800] "GET //beep.wav HTTP/1.1" 200 911
Accepted connection from 192.168.1.105:38671
Handling "POST" "//?"
Failed to find session: oJKOOL5nOVajeCKY-jriuw
192.168.1.105 - - [27/Aug/2010:18:25:03 +0800] "POST //? HTTP/1.1" 400 458
Closing connection to 192.168.1.105:38671

What version of the product are you using? On what operating system?
shellinabox 2.10 | Centos 5.4

Please provide any additional information below.
command listen is an example

Original issue reported on code.google.com by frysha...@gmail.com on 27 Aug 2010 at 10:24

GoogleCodeExporter commented 8 years ago
anyone have a same issue ?

Original comment by frysha...@gmail.com on 11 Sep 2010 at 11:44

GoogleCodeExporter commented 8 years ago
I to, am having this issue. It's very frustrating!

Original comment by noeticpe...@gmail.com on 1 Jan 2011 at 5:20

GoogleCodeExporter commented 8 years ago
more info! stupid enter key! 

I'm using the command mode to issue a svn checkout to help our developers get 
their dev environment setup. partway through it always dies with failed to find 
session.

Original comment by noeticpe...@gmail.com on 1 Jan 2011 at 5:25

GoogleCodeExporter commented 8 years ago
Try to check the PAM config. I modified mine to

#%PAM-1.0
auth       required     pam_nologin.so
auth       include    system-auth
account    include    system-auth
session    include    system-auth
password   include    system-auth

Original comment by frysha...@gmail.com on 1 Jan 2011 at 5:58

GoogleCodeExporter commented 8 years ago
FryShadow,

Do I create a new shellintheboxd file to put that pam information in? or the 
sshd pam config ?

Original comment by noeticpe...@gmail.com on 3 Jan 2011 at 1:10

GoogleCodeExporter commented 8 years ago
this is mine:

# pwd 
/etc/pam.d

# ls -la | grep shellinabox
-rw-r--r--  1 root root     168 Sep 13 15:10 shellinabox

# more shellinabox 
#%PAM-1.0
auth       required     pam_nologin.so
auth       include  system-auth
account    include  system-auth
session    include  system-auth
password   include  system-auth

Original comment by frysha...@gmail.com on 3 Jan 2011 at 1:21

GoogleCodeExporter commented 8 years ago
That actually prevents me from logging in at all. 

This is an LDAP'd system and my user is not local. When I try to log in it 
gives me login incorrect. this is after putting a shellinabox file in the 
/etc/pam.d directory. any ideas? File contents were copy/pasted.

Original comment by noeticpe...@gmail.com on 3 Jan 2011 at 1:27

GoogleCodeExporter commented 8 years ago
I get the same issues with -s /:AUTH:HOME:SHELL , when it works at all (see 
http://code.google.com/p/shellinabox/issues/detail?id=106&q=AUTH )

The suggested pam.d given here doesn't help.  The only output I get on the page 
is:

- -------

Login incorrect
Login incorrect
Maximum number of tries exceeded (3)
Session closed.

- -------

As far as I can tell, only SSH and LOGIN methods work at all; has anyone ever 
gotten the AUTH/user method to work?

-Robin

Original comment by robinleepowell@gmail.com on 3 Aug 2011 at 6:41

GoogleCodeExporter commented 8 years ago
I am getting a similar problem:

[root@luke:/etc/pam.d]# shellinaboxd --no-beep -s /:SSH -t -d Command line: shellinaboxd --no-beep -s /:SSH -t -d Listening on port 4200 Accepted connection from localhost:58928 Handling "GET" "/shell/" localhost - - [01/Dec/2013:16:33:17 +0000] "GET /shell/ HTTP/1.0" 200 4967 Closing connection to localhost:58928 Accepted connection from localhost:58929 Handling "GET" "/shell/styles.css" localhost - - [01/Dec/2013:16:33:17 +0000] "GET /shell/styles.css HTTP/1.0" 200 7286 Closing connection to localhost:58929 Accepted connection from localhost:58930 Handling "GET" "/shell/ShellInABox.js" localhost - - [01/Dec/2013:16:33:17 +0000] "GET /shell/ShellInABox.js HTTP/1.0" 200 188602 Closing connection to localhost:58930 Accepted connection from localhost:58931 Handling "GET" "/shell/keyboard.png" localhost - - [01/Dec/2013:16:33:17 +0000] "GET /shell/keyboard.png HTTP/1.0" 200 873 Closing connection to localhost:58931 Accepted connection from localhost:58932 Handling "GET" "/shell/keyboard.html" localhost - - [01/Dec/2013:16:33:17 +0000] "GET /shell/keyboard.html HTTP/1.0" 200 3181 Closing connection to localhost:58932 Accepted connection from localhost:58933 Handling "POST" "/shell/?" Creating a new session: v/ZHRnhu4kLbmbikeXVVeg Window size changed to 71x40 localhost - - [01/Dec/2013:16:33:17 +0000] "POST /shell/? HTTP/1.0" 200 157 Closing connection to localhost:58933 Accepted connection from localhost:58934 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:17 +0000] "POST /shell/? HTTP/1.0" 200 169 Closing connection to localhost:58934 Accepted connection from localhost:58935 Handling "POST" "/shell/?" Accepted connection from localhost:58936 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58936 localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 158 Closing connection to localhost:58935 Accepted connection from localhost:58937 Handling "POST" "/shell/?" Accepted connection from localhost:58938 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58938 localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 158 Closing connection to localhost:58937 Accepted connection from localhost:58939 Handling "POST" "/shell/?" Accepted connection from localhost:58940 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58940 localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 158 Closing connection to localhost:58939 Accepted connection from localhost:58941 Handling "POST" "/shell/?" Accepted connection from localhost:58942 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:20 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58942 localhost - - [01/Dec/2013:16:33:20 +0000] "POST /shell/? HTTP/1.0" 200 161 Closing connection to localhost:58941 Child terminated Accepted connection from localhost:58943 Handling "POST" "/shell/?" Failed to find session: v/ZHRnhu4kLbmbikeXVVeg localhost - - [01/Dec/2013:16:33:20 +0000] "POST /shell/? HTTP/1.0" 400 458 Closing connection to localhost:58943

Handling "POST" "/shell/?" Accepted connection from localhost:58936 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58936 localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 158 Closing connection to localhost:58935 Accepted connection from localhost:58937 Handling "POST" "/shell/?" Accepted connection from localhost:58938 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58938 localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 158 Closing connection to localhost:58937 Accepted connection from localhost:58939 Handling "POST" "/shell/?" Accepted connection from localhost:58940 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58940 localhost - - [01/Dec/2013:16:33:19 +0000] "POST /shell/? HTTP/1.0" 200 158 Closing connection to localhost:58939 Accepted connection from localhost:58941 Handling "POST" "/shell/?" Accepted connection from localhost:58942 Handling "POST" "/shell/?" localhost - - [01/Dec/2013:16:33:20 +0000] "POST /shell/? HTTP/1.0" 200 407 Closing connection to localhost:58942 localhost - - [01/Dec/2013:16:33:20 +0000] "POST /shell/? HTTP/1.0" 200 161 Closing connection to localhost:58941 Child terminated Accepted connection from localhost:58943 Handling "POST" "/shell/?" Failed to find session: v/ZHRnhu4kLbmbikeXVVeg localhost - - [01/Dec/2013:16:33:20 +0000] "POST /shell/? HTTP/1.0" 400 458 Closing connection to localhost:58943

I have tried several other -s settings. Still get this. I am trying this on 
NixOS. I've build both using a Nix expression and configure/make.

Original comment by tombe...@gmail.com on 1 Dec 2013 at 4:36

GoogleCodeExporter commented 8 years ago
I was able to get SSL working, but the session still closes right after I type 
in a username:
localhost - - [01/Dec/2013:13:06:30 -0500] "GET /enabled.gif HTTP/1.1" 200 912
Handling "POST" "/?"
localhost - - [01/Dec/2013:13:06:35 -0500] "POST /? HTTP/1.1" 200 407
localhost - - [01/Dec/2013:13:06:35 -0500] "POST /? HTTP/1.1" 200 161
Child terminated
Handling "POST" "/?"
Failed to find session: FcOP-UBevoCJDFQHeukSmA
localhost - - [01/Dec/2013:13:06:35 -0500] "POST /? HTTP/1.1" 400 458
Closing connection to localhost:59904
^CShutting down server
Closing connection to localhost:59907
Done

Original comment by tombe...@gmail.com on 1 Dec 2013 at 6:09

GoogleCodeExporter commented 8 years ago
I was having this issue as well under the SSH service.  You might want to 
ensure that your hostname resolves to the correct IP.  It would be nice for the 
error in debug to indicate the SSH/DNS failure rather than "Failed to find 
session" when this is the case.

Original comment by konce...@gmail.com on 4 Dec 2013 at 11:40

GoogleCodeExporter commented 8 years ago
I've tried both IP and hostname.

Original comment by tombe...@gmail.com on 6 Dec 2013 at 4:10

GoogleCodeExporter commented 8 years ago
Looking at the command you are running
"[root@luke:/etc/pam.d]# shellinaboxd --no-beep -s /:SSH -t -d"
Does "luke" resolve?  When shellinabox tries to open the ssh connection it does 
ssh .... user@host, in your case luke.  If luke doesn't resolve to an IP where 
ssh is listening then it will close quickly like you are experiencing.  You can 
resolve this by editing /etc/hosts if this is a standalone box and adding a 
line that is "luke <tab> <your pub ip>"  This makes the most sense if it is a 
static IP.  If it is dynamic you can put it in the line with 127.0.0.1.  The 
other option is getting the hostname to match up to dns properly so if your 
hostname is luke and your domain is acme.com then luke.acme.com needs to 
resolve to your IP.

Original comment by konce...@gmail.com on 6 Dec 2013 at 11:49

GoogleCodeExporter commented 8 years ago
Yeah, luke resolves. I've added it to my /etc/hosts, I can go to luke:4200 and 
it brings up the login, but as soon as I hit enter to write the password, it 
pops up with "Failed to find session" in the debug output and "Session closed" 
in the browser.

Original comment by tombe...@gmail.com on 7 Dec 2013 at 3:39

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
For future readers :)

I had the same issue on my CentOS 6.6 and I found out that the code from 
shellinabox/launcher.c replaces "@localhost" in ssh command with 
"@hostname.domain" (output of command uname -n) ...

[luka@hostname shellinabox]$ uname -n
hostname.domain

This is quick patch that I am using (but than you missout on nice shell prompt):

diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c
index 68d8862..3aa9100 100644
--- a/shellinabox/launcher.c
+++ b/shellinabox/launcher.c
@@ -1000,16 +1000,16 @@ static pam_handle_t *internalLogin(struct Service 
*service, struct Utmp *utmp,

     // Replace '@localhost' with the actual host name. This results in a nicer
     // prompt when SSH asks for the password.
-    char *ptr                  = strrchr(cmdline, '@');
-    if (!strcmp(ptr + 1, "localhost")) {
-      int offset               = ptr + 1 - cmdline;
-      check(cmdline            = realloc(cmdline,
-                                         strlen(cmdline) + strlen(fqdn) -
-                                         strlen("localhost") + 1));
-      ptr                      = cmdline + offset;
-      *ptr                     = '\000';
-      strncat(ptr, fqdn, strlen(fqdn));
-    }
+    // char *ptr                  = strrchr(cmdline, '@');
+    // if (!strcmp(ptr + 1, "localhost")) {
+    //   int offset               = ptr + 1 - cmdline;
+    //   check(cmdline            = realloc(cmdline,
+    //                                     strlen(cmdline) + strlen(fqdn) -
+    //                                     strlen("localhost") + 1));
+    //   ptr                      = cmdline + offset;
+    //   *ptr                     = '\000';
+    //   strncat(ptr, fqdn, strlen(fqdn));
+    // }

     free((void *)service->cmdline);
     service->cmdline           = cmdline;

I think that the correct thing to do here is to configure host and domain name, 
but i didn't try that (/etc/hosts and /etc/resolv.conf) ...

Original comment by luka.kra...@gmail.com on 12 Jan 2015 at 9:16