tmux start in detach mode problem.

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

tmux start in detach mode problem.

Postby ferus » Sun Feb 05, 2012 10:47 am

Hi i have one simple problem with phpseclib. I am using it to start/stop/restart application services in detached mode (i.e. Minecraft servers). Everything is working fine for stop/restart functions. But when it comes to start command i am using
Code: Select all
tmux new -d -s rest of command


command to create new tmux detached session, php script gone bananas. It's look like after calling this command phpseclib is not returning a logic value or an output so it crashes php script.
BUT - there is a fun part. It is executing this command, beacuse it is really creating new session but just don't returning control to php script.

I am using tmux instead of screen beacuse of his limits. Please - try it yourself and if it is a bug - please correct it - i cannot "really" install SSH2 for PHP but i'd love to work with phpseclib.

Cheers.
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby ferus » Thu Feb 09, 2012 7:55 pm

Small update - i have configured ssh2_connect (native PHP library) and every command runs like a charm - it is phpseclib error definitely.
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby TerraFrost » Sun Feb 12, 2012 2:18 am

A few things.

  1. You say tmux is crashing phpseclib. How is it crashing? Are you getting a "Fatal error"? Are you getting a "Notice"? Core dump? Saying it's crashing and leaving it at that isn't particurarly helpful.

    If you're getting "Fatal error", in addition to telling me what the error actually is, doing the following might provide some additional insight:

    Code: Select all
    function show_debug()
    {
       global $ssh;
       echo $ssh->getLog();
    }

    register_shutdown_function('show_debug');
  2. It's a shot in the dark but... try this:

    Code: Select all
    #
    #-----[ OPEN ]------------------------------------------
    #
    Net/SSH2.php
    #
    #-----[ FIND ]------------------------------------------
    #
            // sending a pty-req SSH_MSG_CHANNEL_REQUEST message is unnecessary and, in fact, in most cases, slows things
            // down.  the one place where it might be desirable is if you're doing something like Net_SSH2::exec('ping localhost &').
            // with a pty-req SSH_MSG_CHANNEL_REQUEST, exec() will return immediately and the ping process will then
            // then immediately terminate.  without such a request exec() will loop indefinitely.  the ping process won't end but
            // neither will your script.
    #
    #-----[ REPLACE WITH ]----------------------------------
    #
            $terminal_modes = pack('C', NET_SSH2_TTY_OP_END);
            $packet = pack('CNNa*CNa*N5a*',
                NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SSH2_CHANNEL_EXEC], strlen('pty-req'), 'pty-req', 1, strlen('vt100'), 'vt100',
                80, 24, 0, 0, strlen($terminal_modes), $terminal_modes);

            if (!$this->_send_binary_packet($packet)) {
                return false;
            }
  3. I don't know shit about tmux and your post is pretty much akin to telling me to "figure [tmux] out yourself". If there's a problem help me help you.

    As is, let me give you a run down of what I did and why I'm a little annoyed with you and your post.

    I tried to install tmux on an Ubuntu LiveCD I have lying around and got the following:

    Code: Select all
    ubuntu@ubuntu:~$ sudo apt-get install tmux
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package tmux

    When I tried to run tmux via the CLI I got this:

    Code: Select all
    The program 'tmux' is currently not installed.  You can install it by typing:
    sudo apt-get install tmux
    You will have to enable the component called 'universe'

    I did some Google searches and found that I could enable 'universe' by editing /etc/apt/sources.list. But wait! I'm on an Ubuntu LiveCD so apparently I can't!

    I tried it on a Fedore Core machine I have and got the following:

    Code: Select all
    [root@somemachine:~]$sudo yum install tmux
    Loaded plugins: fastestmirror
    Determining fastest mirrors
     * updates-newkey: kdeforge.unl.edu
     * fedora: kdeforge.unl.edu
     * updates: kdeforge.unl.edu
    updates-newkey                                           | 2.3 kB     00:00
    fedora                                                   | 2.1 kB     00:00
    updates                                                  | 2.6 kB     00:00
    Setting up Install Process
    Parsing package install arguments
    No package tmux available.
    Nothing to do


    When I finally do manage to get tmux installed I don't have any problems. I do this to make sure my syntax is correct:

    Code: Select all
    tmux new -d -s ls

    I don't get any errors so I assume it is. I then try to do it with phpseclib and I get a "duplicate session: ls" message. I tried ls2 and I didn't get that message. Maybe that means it does work for me? I have no clue.

    Like I said, I don't know shit about tmux. And assuming that I know everything about every distro of Linux under the sun because I implemented SSH is equally falacious because SSH != Linux.
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: tmux start in detach mode problem.

Postby ferus » Sun Feb 26, 2012 5:53 pm

Hi - sorry for no reply - i was superb busy.

First of all, i got a NOTICE of maximum execution time exceeded (60 seconds set here on home basis).
After your lines correction i'm getting:

Code: Select all
Notice: Error reading channel data in C:\xampp\xampp\htdocs\tests\Net\SSH2.php on line 2125


And i am attaching my test code (I've just taken it from my final application).
Login credentials were removed ;)

Additionally, i get no msg from register_shutdown_function();

Please ask further questions - i will answer them all.
My Linux distribution is Debian:

Code: Select all
Distributor ID: Debian
Description:    Debian GNU/Linux 6.0.3 (squeeze)
Release:        6.0.3
Codename:       squeeze


Code: Select all
<?php
include('Net/SSH2.php');

function show_debug()
{
   global $ssh;
   echo $ssh->getLog();
}

register_shutdown_function('show_debug');

$ssh = new Net_SSH2('domain.com',port);
if (!$ssh->login('login', 'pass')) {
    exit('Login Failed');
}
$cmd = "cd ~/176.31.100.80-25574;tmux new -d -s ferus-game \"java -Xms512M -Xmx512M -jar minecraft_server.jar nogui\"";
echo $ssh->exec($cmd);
?>


PS Note that session is created on the linux side after calling this request.
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby TerraFrost » Tue Feb 28, 2012 6:54 am

I'll try to take a look tomorrow. Off hand I can say that you're using the latest release version and not the latest SVN. Might be worthwhile to give that one a shot.

Also, did you try the "shot in the dark" #2?
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: tmux start in detach mode problem.

Postby ferus » Tue Feb 28, 2012 7:59 pm

You've just gave me a one "shot in dark" clue.
I will try SVN version.

edit: I've tried SVN version, then SVN version with your "shot in the dark" idea - still all the same.

Code: Select all
Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\xampp\htdocs\tests\Net\SSH2.php on line 1874
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby TerraFrost » Thu Mar 01, 2012 6:23 am

For the register_shutdown_function() you also need to do define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX). eg.

Code: Select all
<?php
set_time_limit(4);

function show_debug()
{
   global $ssh;
   echo $ssh->getLog();
}

register_shutdown_function('show_debug');

include('Net/SSH2.php');

define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

$ssh = new Net_SSH2('domain.tld');
$ssh->login('user', 'pass');

echo $ssh->exec('ping 127.0.0.1');


You've just gave me a one "shot in dark" clue.

Yeah - I just mentioned it in the #2 bullet lol.
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: tmux start in detach mode problem.

Postby ferus » Thu Mar 01, 2012 6:51 am

If you mean replacing a code as a second "shot in the dark", yeah i've done this every combination you could possible imagine ;)
Also, i got log you've requested. Thanks for your time, just from that point, you're doing great job.

Code: Select all
<- 00000000 53:53:48:2d:32:2e:30:2d:4f:70:65:6e:53:53:48:5f SSH-2.0-OpenSSH_ 00000010 35:2e:35:70:31:20:44:65:62:69:61:6e:2d:36:2b:73 5.5p1 Debian-6+s 00000020 71:75:65:65:7a:65:31:0d:0a queeze1.. -> 00000000 53:53:48:2d:32:2e:30:2d:70:68:70:73:65:63:6c:69 SSH-2.0-phpsecli 00000010 62:5f:30:2e:32:20:28:6d:63:72:79:70:74:2c:20:62 b_0.2 (mcrypt, b 00000020 63:6d:61:74:68:29:0d:0a cmath).. <- NET_SSH2_MSG_KEXINIT (0.0357s) 00000000 b5:42:77:03:df:7c:ff:5a:fd:51:ad:ec:a2:0b:94:97 .Bw..|.Z.Q...... 00000010 00:00:00:7e:64:69:66:66:69:65:2d:68:65:6c:6c:6d ...~diffie-hellm 00000020 61:6e:2d:67:72:6f:75:70:2d:65:78:63:68:61:6e:67 an-group-exchang 00000030 65:2d:73:68:61:32:35:36:2c:64:69:66:66:69:65:2d e-sha256,diffie- 00000040 68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:2d:65:78 hellman-group-ex 00000050 63:68:61:6e:67:65:2d:73:68:61:31:2c:64:69:66:66 change-sha1,diff 00000060 69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70 ie-hellman-group 00000070 31:34:2d:73:68:61:31:2c:64:69:66:66:69:65:2d:68 14-sha1,diffie-h 00000080 65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:31:2d:73:68 ellman-group1-sh 00000090 61:31:00:00:00:0f:73:73:68:2d:72:73:61:2c:73:73 a1....ssh-rsa,ss 000000a0 68:2d:64:73:73:00:00:00:9d:61:65:73:31:32:38:2d h-dss....aes128- 000000b0 63:74:72:2c:61:65:73:31:39:32:2d:63:74:72:2c:61 ctr,aes192-ctr,a 000000c0 65:73:32:35:36:2d:63:74:72:2c:61:72:63:66:6f:75 es256-ctr,arcfou 000000d0 72:32:35:36:2c:61:72:63:66:6f:75:72:31:32:38:2c r256,arcfour128, 000000e0 61:65:73:31:32:38:2d:63:62:63:2c:33:64:65:73:2d aes128-cbc,3des- 000000f0 63:62:63:2c:62:6c:6f:77:66:69:73:68:2d:63:62:63 cbc,blowfish-cbc 00000100 2c:63:61:73:74:31:32:38:2d:63:62:63:2c:61:65:73 ,cast128-cbc,aes 00000110 31:39:32:2d:63:62:63:2c:61:65:73:32:35:36:2d:63 192-cbc,aes256-c 00000120 62:63:2c:61:72:63:66:6f:75:72:2c:72:69:6a:6e:64 bc,arcfour,rijnd 00000130 61:65:6c:2d:63:62:63:40:6c:79:73:61:74:6f:72:2e ael-cbc@lysator. 00000140 6c:69:75:2e:73:65:00:00:00:9d:61:65:73:31:32:38 liu.se....aes128 00000150 2d:63:74:72:2c:61:65:73:31:39:32:2d:63:74:72:2c -ctr,aes192-ctr, 00000160 61:65:73:32:35:36:2d:63:74:72:2c:61:72:63:66:6f aes256-ctr,arcfo 00000170 75:72:32:35:36:2c:61:72:63:66:6f:75:72:31:32:38 ur256,arcfour128 00000180 2c:61:65:73:31:32:38:2d:63:62:63:2c:33:64:65:73 ,aes128-cbc,3des 00000190 2d:63:62:63:2c:62:6c:6f:77:66:69:73:68:2d:63:62 -cbc,blowfish-cb 000001a0 63:2c:63:61:73:74:31:32:38:2d:63:62:63:2c:61:65 c,cast128-cbc,ae 000001b0 73:31:39:32:2d:63:62:63:2c:61:65:73:32:35:36:2d s192-cbc,aes256- 000001c0 63:62:63:2c:61:72:63:66:6f:75:72:2c:72:69:6a:6e cbc,arcfour,rijn 000001d0 64:61:65:6c:2d:63:62:63:40:6c:79:73:61:74:6f:72 dael-cbc@lysator 000001e0 2e:6c:69:75:2e:73:65:00:00:00:69:68:6d:61:63:2d .liu.se...ihmac- 000001f0 6d:64:35:2c:68:6d:61:63:2d:73:68:61:31:2c:75:6d md5,hmac-sha1,um 00000200 61:63:2d:36:34:40:6f:70:65:6e:73:73:68:2e:63:6f ac-64@openssh.co 00000210 6d:2c:68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30 m,hmac-ripemd160 00000220 2c:68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30:40 ,hmac-ripemd160@ 00000230 6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63 openssh.com,hmac 00000240 2d:73:68:61:31:2d:39:36:2c:68:6d:61:63:2d:6d:64 -sha1-96,hmac-md 00000250 35:2d:39:36:00:00:00:69:68:6d:61:63:2d:6d:64:35 5-96...ihmac-md5 00000260 2c:68:6d:61:63:2d:73:68:61:31:2c:75:6d:61:63:2d ,hmac-sha1,umac- 00000270 36:34:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68 64@openssh.com,h 00000280 6d:61:63:2d:72:69:70:65:6d:64:31:36:30:2c:68:6d mac-ripemd160,hm 00000290 61:63:2d:72:69:70:65:6d:64:31:36:30:40:6f:70:65 ac-ripemd160@ope 000002a0 6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68 nssh.com,hmac-sh 000002b0 61:31:2d:39:36:2c:68:6d:61:63:2d:6d:64:35:2d:39 a1-96,hmac-md5-9 000002c0 36:00:00:00:15:6e:6f:6e:65:2c:7a:6c:69:62:40:6f 6....none,zlib@o 000002d0 70:65:6e:73:73:68:2e:63:6f:6d:00:00:00:15:6e:6f penssh.com....no 000002e0 6e:65:2c:7a:6c:69:62:40:6f:70:65:6e:73:73:68:2e ne,zlib@openssh. 000002f0 63:6f:6d:00:00:00:00:00:00:00:00:00:00:00:00:00 com............. -> NET_SSH2_MSG_KEXINIT (0s) 00000000 04:81:71:9e:95:1f:d0:fe:9d:17:6b:4a:b7:b8:f1:a6 ..q.......kJ.... 00000010 00:00:00:36:64:69:66:66:69:65:2d:68:65:6c:6c:6d ...6diffie-hellm 00000020 61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:2c:64 an-group1-sha1,d 00000030 69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72 iffie-hellman-gr 00000040 6f:75:70:31:34:2d:73:68:61:31:00:00:00:0f:73:73 oup14-sha1....ss 00000050 68:2d:72:73:61:2c:73:73:68:2d:64:73:73:00:00:00 h-rsa,ssh-dss... 00000060 76:61:72:63:66:6f:75:72:32:35:36:2c:61:72:63:66 varcfour256,arcf 00000070 6f:75:72:31:32:38:2c:61:72:63:66:6f:75:72:2c:61 our128,arcfour,a 00000080 65:73:31:32:38:2d:63:62:63:2c:61:65:73:31:39:32 es128-cbc,aes192 00000090 2d:63:62:63:2c:61:65:73:32:35:36:2d:63:62:63:2c -cbc,aes256-cbc, 000000a0 61:65:73:31:32:38:2d:63:74:72:2c:61:65:73:31:39 aes128-ctr,aes19 000000b0 32:2d:63:74:72:2c:61:65:73:32:35:36:2d:63:74:72 2-ctr,aes256-ctr 000000c0 2c:33:64:65:73:2d:63:74:72:2c:33:64:65:73:2d:63 ,3des-ctr,3des-c 000000d0 62:63:2c:6e:6f:6e:65:00:00:00:76:61:72:63:66:6f bc,none...varcfo 000000e0 75:72:32:35:36:2c:61:72:63:66:6f:75:72:31:32:38 ur256,arcfour128 000000f0 2c:61:72:63:66:6f:75:72:2c:61:65:73:31:32:38:2d ,arcfour,aes128- 00000100 63:62:63:2c:61:65:73:31:39:32:2d:63:62:63:2c:61 cbc,aes192-cbc,a 00000110 65:73:32:35:36:2d:63:62:63:2c:61:65:73:31:32:38 es256-cbc,aes128 00000120 2d:63:74:72:2c:61:65:73:31:39:32:2d:63:74:72:2c -ctr,aes192-ctr, 00000130 61:65:73:32:35:36:2d:63:74:72:2c:33:64:65:73:2d aes256-ctr,3des- 00000140 63:74:72:2c:33:64:65:73:2d:63:62:63:2c:6e:6f:6e ctr,3des-cbc,non 00000150 65:00:00:00:30:68:6d:61:63:2d:73:68:61:31:2d:39 e...0hmac-sha1-9 00000160 36:2c:68:6d:61:63:2d:73:68:61:31:2c:68:6d:61:63 6,hmac-sha1,hmac 00000170 2d:6d:64:35:2d:39:36:2c:68:6d:61:63:2d:6d:64:35 -md5-96,hmac-md5 00000180 2c:6e:6f:6e:65:00:00:00:30:68:6d:61:63:2d:73:68 ,none...0hmac-sh 00000190 61:31:2d:39:36:2c:68:6d:61:63:2d:73:68:61:31:2c a1-96,hmac-sha1, 000001a0 68:6d:61:63:2d:6d:64:35:2d:39:36:2c:68:6d:61:63 hmac-md5-96,hmac 000001b0 2d:6d:64:35:2c:6e:6f:6e:65:00:00:00:04:6e:6f:6e -md5,none....non 000001c0 65:00:00:00:04:6e:6f:6e:65:00:00:00:00:00:00:00 e....none....... 000001d0 00:00:00:00:00:00 ...... -> NET_SSH2_MSG_KEXDH_INIT (0.0001s) 00000000 00:00:00:81:00:a9:2a:0c:4e:3b:00:b0:d1:6f:df:d5 ......*.N;...o.. 00000010 48:bf:af:ee:27:00:94:d8:34:a4:38:51:0e:a9:e7:9c H...'...4.8Q.... 00000020 85:cd:be:b3:e7:6b:97:53:fe:90:d5:6f:c3:00:d1:cf .....k.S...o.... 00000030 c4:af:e7:4e:b7:86:66:f4:ff:9f:75:d1:81:6a:cf:09 ...N..f...u..j.. 00000040 62:52:5e:e7:ad:f0:ba:bf:5b:0f:22:26:0f:dd:3b:bc bR^.....[."&..;. 00000050 58:02:cc:76:47:6f:91:8f:28:8c:fc:95:2a:11:4b:64 X..vGo..(...*.Kd 00000060 ba:7a:30:fa:cd:a7:86:ea:86:39:c9:f1:c8:36:54:b0 .z0......9...6T. 00000070 c8:08:1a:52:be:96:1b:03:b1:2f:80:70:8f:0e:bc:0c ...R...../.p.... 00000080 77:c1:e9:0c:cb w.... <- NET_SSH2_MSG_KEXDH_REPLY (0.0354s) 00000000 00:00:01:15:00:00:00:07:73:73:68:2d:72:73:61:00 ........ssh-rsa. 00000010 00:00:01:23:00:00:01:01:00:b6:a2:16:f5:ef:11:4b ...#...........K 00000020 64:f1:41:b5:41:40:aa:69:0c:80:0c:6c:ac:08:54:ab d.A.A@.i...l..T. 00000030 53:5e:20:3a:5b:f7:88:d7:48:a3:35:cb:2e:70:f5:14 S^ :[...H.5..p.. 00000040 f7:6a:e0:33:ac:4c:74:a1:a1:98:aa:ba:30:4d:7a:44 .j.3.Lt.....0MzD 00000050 c8:65:9e:79:3c:c1:e0:ca:05:28:ff:ae:0f:76:3b:96 .e.y.....(...v;. 00000060 b8:13:fd:0d:97:0f:e8:a9:18:5c:a3:6c:45:53:60:b6 .........\.lES`. 00000070 a9:81:1c:60:ad:34:91:a4:de:59:6e:4a:39:c1:bf:a0 ...`.4...YnJ9... 00000080 ba:cd:44:3a:ca:77:e3:89:7b:19:41:79:42:93:c5:43 ..D:.w..{.AyB..C 00000090 54:e4:71:b9:e6:8f:ec:46:f6:7f:c0:7a:76:a3:79:ba T.q....F...zv.y. 000000a0 e6:a6:3f:e2:1f:db:36:29:1c:b5:9a:a9:31:79:30:c1 ..?...6)....1y0. 000000b0 ce:f0:f5:73:64:96:41:91:84:09:e2:3c:d7:a7:69:59 ...sd.A.......iY 000000c0 fb:dd:4c:ee:a5:77:90:a6:2e:0c:eb:9c:eb:be:53:06 ..L..w........S. 000000d0 3c:fb:29:96:61:78:58:ff:c2:81:05:fd:e4:47:b9:f9 ..).axX......G.. 000000e0 5c:82:d8:34:d3:5c:7d:4f:f3:5a:4c:e3:f5:da:5a:33 \..4.\}O.ZL...Z3 000000f0 2e:92:19:97:35:30:75:1e:8d:17:81:b6:0f:d6:1f:a6 ....50u......... 00000100 d4:d3:be:db:9c:39:63:0c:45:61:38:cf:7c:e9:6c:fa .....9c.Ea8.|.l. 00000110 67:fc:30:35:2e:60:b5:d8:8d:00:00:00:80:18:82:81 g.05.`.......... 00000120 f8:4c:6d:92:1f:ec:c0:19:bf:09:e6:c4:bd:3a:dd:2b .Lm..........:.+ 00000130 0e:88:e9:c2:91:8c:73:0e:f7:dd:cf:87:43:f5:aa:c4 ......s.....C... 00000140 0b:d0:b3:74:9a:33:fc:3b:5d:8d:10:82:16:1b:3e:21 ...t.3.;].....>! 00000150 5b:c8:8d:5b:60:84:09:45:23:4a:0c:d4:ab:55:ac:13 [..[`..E#J...U.. 00000160 2b:27:7b:36:57:fc:b4:07:d8:b1:e9:13:99:83:4b:b1 +'{6W.........K. 00000170 9f:32:cc:e1:bc:48:27:ec:a3:9e:f5:60:17:45:46:bc .2...H'....`.EF. 00000180 50:72:d7:c6:cf:43:dd:c1:fb:60:2a:50:d5:39:85:ff Pr...C...`*P.9.. 00000190 00:e7:b2:4f:6b:60:9a:3c:41:6e:90:e1:d1:00:00:01 ...Ok`..An...... 000001a0 0f:00:00:00:07:73:73:68:2d:72:73:61:00:00:01:00 .....ssh-rsa.... 000001b0 15:a4:37:ed:6c:4a:84:29:26:82:07:1c:29:01:39:54 ..7.lJ.)&...).9T 000001c0 b0:62:02:d7:0d:27:80:06:e4:25:61:ae:f4:c7:df:56 .b...'...%a....V 000001d0 96:7e:39:20:0d:e7:e0:1f:17:f9:10:66:e6:e2:3d:84 .~9 .......f..=. 000001e0 5e:86:b7:ac:d4:25:cb:bf:c9:f8:21:7f:8b:48:bd:30 ^....%....!..H.0 000001f0 47:ed:8f:f7:8e:5b:95:5f:04:3b:06:41:e7:44:d2:ce G....[._.;.A.D.. 00000200 82:78:34:d1:3b:82:75:50:f5:0a:20:a6:de:e6:3c:7d .x4.;.uP.. ....} 00000210 96:b5:11:e5:ab:07:a9:90:95:dc:94:90:36:0e:60:5e ............6.`^ 00000220 66:b9:49:c2:65:ad:74:15:10:b1:d5:81:d9:92:d1:87 f.I.e.t......... 00000230 a0:7e:c6:c8:71:00:2b:8a:4a:dc:85:81:c4:5a:3c:12 .~..q.+.J....Z.. 00000240 22:64:d5:0d:20:4f:15:6b:1c:4e:64:e5:c9:6a:64:30 "d.. O.k.Nd..jd0 00000250 21:f7:96:8a:f8:84:77:3d:7d:28:a0:ee:4f:25:85:28 !.....w=}(..O%.( 00000260 2d:5e:47:fa:3c:5c:ba:0f:ea:fb:ef:e1:e3:23:8d:54 -^G..\.......#.T 00000270 a1:93:db:b4:7a:e8:e5:d3:97:3c:fe:17:4f:c6:f7:59 ....z.......O..Y 00000280 04:e9:87:61:e5:c3:01:53:86:62:28:6f:a8:ee:0a:f2 ...a...S.b(o.... 00000290 32:36:8f:53:05:1f:47:6e:a5:d7:e0:07:24:fc:bc:a7 26.S..Gn....$... 000002a0 f1:48:a2:28:7a:8d:47:ab:1e:87:23:b5:54:40:c9:f8 .H.(z.G...#.T@.. -> NET_SSH2_MSG_NEWKEYS (0.0001s) <- NET_SSH2_MSG_NEWKEYS (0s) -> NET_SSH2_MSG_SERVICE_REQUEST (0s) 00000000 00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68 ....ssh-userauth <- NET_SSH2_MSG_SERVICE_ACCEPT (0.1026s) 00000000 00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68 ....ssh-userauth -> NET_SSH2_MSG_USERAUTH_REQUEST (0.0001s) 00000000 32:00:00:00:08:75:73:65:72:6e:61:6d:65:00:00:00 2....username... 00000010 0e:73:73:68:2d:63:6f:6e:6e:65:63:74:69:6f:6e:00 .ssh-connection. 00000020 00:00:08:70:61:73:73:77:6f:72:64:00:00:00:00:08 ...password..... 00000030 70:61:73:73:77:6f:72:64 password <- NET_SSH2_MSG_USERAUTH_SUCCESS (1.7613s) -> NET_SSH2_MSG_CHANNEL_OPEN (0s) 00000000 00:00:00:07:73:65:73:73:69:6f:6e:00:00:00:00:7f ....session..... 00000010 ff:ff:ff:00:00:40:00 .....@. <- NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION (0.0323s) 00000000 00:00:00:00:00:00:00:00:00:00:00:00:00:00:80:00 ................ -> NET_SSH2_MSG_CHANNEL_REQUEST (0s) 00000000 00:00:00:00:00:00:00:04:65:78:65:63:01:00:00:00 ........exec.... 00000010 6b:63:64:20:7e:2f:31:37:36:2e:33:31:2e:31:30:30 kcd ~/176.31.100 00000020 2e:38:30:2d:32:35:35:37:34:3b:74:6d:75:78:20:6e .80-25574;tmux n 00000030 65:77:20:2d:64:20:2d:73:20:66:65:72:75:73:2d:67 ew -d -s ferus-g 00000040 61:6d:65:20:22:6a:61:76:61:20:2d:58:6d:73:35:31 ame "java -Xms51 00000050 32:4d:20:2d:58:6d:78:35:31:32:4d:20:2d:6a:61:72 2M -Xmx512M -jar 00000060 20:6d:69:6e:65:63:72:61:66:74:5f:73:65:72:76:65 minecraft_serve 00000070 72:2e:6a:61:72:20:6e:6f:67:75:69:22 r.jar nogui" <- NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST (0.0325s) 00000000 00:00:00:00:00:20:00:00 ..... .. <- NET_SSH2_MSG_CHANNEL_SUCCESS (0s) 00000000 00:00:00:00 .... <- NET_SSH2_MSG_CHANNEL_REQUEST (0.0269s) 00000000 00:00:00:00:00:00:00:0b:65:78:69:74:2d:73:74:61 ........exit-sta 00000010 74:75:73:00:00:00:00:00 tus.....
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby TerraFrost » Sat Mar 03, 2012 11:26 pm

After running your logs through this script (it'd have been easier if you encapsulated your logs within <pre> tags)... does $ssh->exec('ls -la > /dev/null') yield the same results? I did it on my SSH server and got the following:

Code: Select all
<- NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST (0.0477s)
00000000  00:00:00:00:00:20:00:00                          ..... ..

<- NET_SSH2_MSG_CHANNEL_SUCCESS (0s)
00000000  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_EOF (0.0087s)
00000000  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_REQUEST (0s)
00000000  00:00:00:00:00:00:00:0b:65:78:69:74:2d:73:74:61  ........exit-sta
00000010  74:75:73:00:00:00:00:00                          tus.....

<- NET_SSH2_MSG_CHANNEL_CLOSE (0s)
00000000  00:00:00:00                                      ....

tmux, on your server, yields the following:

Code: Select all
<- NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST (0.0325s)
00000000  00:00:00:00:00:20:00:00                          .....

<- NET_SSH2_MSG_CHANNEL_SUCCESS (0s)
00000000  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_REQUEST (0.0269s)
00000000  00:00:00:00:00:00:00:0b:65:78:69:74:2d:73:74:61  ........exit-sta
00000010  74:75:73:00:00:00:00:00                          tus.....
Note how your SSH server isn't sending a NET_SSH2_MSG_CHANNEL_CLOSE whereas mine is. Because of that phpseclib is stalling, waiting for a message that's never being sent. Maybe the PECL SSH2 extension sends a NET_SSH2_MSG_CHANNEL_CLOSE after the exit-status message, I don't know.

My recommendation is this: using the latest SVN do $ssh->setTimeout(2). That'll make it so phpseclib sends a NET_SSH2_MSG_CHANNEL_CLOSE after two seconds even if it receives no NET_SSH2_MSG_CHANNEL_CLOSE.
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: tmux start in detach mode problem.

Postby ferus » Sun Mar 04, 2012 9:27 pm

Executing
Code: Select all
$ssh->exec('ls -la > /dev/null');


Gave me this log:

Code: Select all
-> NET_SSH2_MSG_SERVICE_REQUEST (0s)
00000000                                                   00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68

<- NET_SSH2_MSG_SERVICE_ACCEPT (0.104s)
00000000                                                   00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68

-> NET_SSH2_MSG_USERAUTH_REQUEST (0s)
00000000                                                   32:00:00:00:08:75:73:65:72:6e:61:6d:65:00:00:00
00000010                                                   0e:73:73:68:2d:63:6f:6e:6e:65:63:74:69:6f:6e:00
00000020                                                   00:00:08:70:61:73:73:77:6f:72:64:00:00:00:00:08
00000030                                                   70:61:73:73:77:6f:72:64

<- NET_SSH2_MSG_USERAUTH_SUCCESS (0.0443s)

-> NET_SSH2_MSG_CHANNEL_OPEN (0s)
00000000                                                   00:00:00:07:73:65:73:73:69:6f:6e:00:00:00:00:7f
00000010                                                   ff:ff:ff:00:00:40:00

<- NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION (0.034s)
00000000                                                   00:00:00:00:00:00:00:00:00:00:00:00:00:00:80:00

-> NET_SSH2_MSG_CHANNEL_REQUEST (0s)
00000000                                                   00:00:00:00:00:00:00:04:65:78:65:63:01:00:00:00
00000010                                                   12:6c:73:20:2d:6c:61:20:3e:20:2f:64:65:76:2f:6e
00000020                                                   75:6c:6c

<- NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST (0.0343s)
00000000                                                   00:00:00:00:00:20:00:00

<- NET_SSH2_MSG_CHANNEL_SUCCESS (0s)
00000000                                                   00:00:00:00

<- NET_SSH2_MSG_CHANNEL_REQUEST (0.0032s)
00000000                                                   00:00:00:00:00:00:00:0b:65:78:69:74:2d:73:74:61
00000010                                                   74:75:73:00:00:00:00:00

<- NET_SSH2_MSG_CHANNEL_EOF (0s)
00000000                                                   00:00:00:00

<- NET_SSH2_MSG_CHANNEL_CLOSE (0s)
00000000                                                   00:00:00:00

-> NET_SSH2_MSG_CHANNEL_CLOSE (0s)
00000000                                                   00:00:00:00



Then i tryied to run my command:
Code: Select all
$ssh->exec('cd ~/176.31.100.80-25574;tmux new -d -s ferus-game `java -Xms512M -Xmx512M -jar minecraft_server.jar nogui`');



Calling command line with setTimeout set to 10 returned this log:
Code: Select all
Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\xampp\htdocs\tests\Net\SSH2.php on line 1909
-> NET_SSH2_MSG_SERVICE_REQUEST (0s)
00000000                                                   00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68

<- NET_SSH2_MSG_SERVICE_ACCEPT (0.1072s)
00000000                                                   00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68

-> NET_SSH2_MSG_USERAUTH_REQUEST (0s)
00000000                                                   32:00:00:00:08:75:73:65:72:6e:61:6d:65:00:00:00
00000010                                                   0e:73:73:68:2d:63:6f:6e:6e:65:63:74:69:6f:6e:00
00000020                                                   00:00:08:70:61:73:73:77:6f:72:64:00:00:00:00:08
00000030                                                   70:61:73:73:77:6f:72:64

<- NET_SSH2_MSG_USERAUTH_SUCCESS (0.0426s)

-> NET_SSH2_MSG_CHANNEL_OPEN (0s)
00000000                                                   00:00:00:07:73:65:73:73:69:6f:6e:00:00:00:00:7f
00000010                                                   ff:ff:ff:00:00:40:00

<- NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION (0s)
00000000                                                   00:00:00:00:00:00:00:00:00:00:00:00:00:00:80:00

-> NET_SSH2_MSG_CHANNEL_REQUEST (0s)
00000000                                                   00:00:00:00:00:00:00:04:65:78:65:63:01:00:00:00
00000010                                                   6b:63:64:20:7e:2f:31:37:36:2e:33:31:2e:31:30:30
00000020                                                   2e:38:30:2d:32:35:35:37:34:3b:74:6d:75:78:20:6e
00000030                                                   65:77:20:2d:64:20:2d:73:20:66:65:72:75:73:2d:67
00000040                                                   61:6d:65:20:60:6a:61:76:61:20:2d:58:6d:73:35:31
00000050                                                   32:4d:20:2d:58:6d:78:35:31:32:4d:20:2d:6a:61:72
00000060                                                   20:6d:69:6e:65:63:72:61:66:74:5f:73:65:72:76:65
00000070                                                   72:2e:6a:61:72:20:6e:6f:67:75:69:60

<- NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST (0s)
00000000                                                   00:00:00:00:00:20:00:00

<- NET_SSH2_MSG_CHANNEL_SUCCESS (0s)
00000000                                                   00:00:00:00

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:41:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:49:4e:46:4f:5d:20:53:74:61:72:74:69:6e:67:20
00000030                                                   6d:69:6e:65:63:72:61:66:74:20:73:65:72:76:65:72
00000040                                                   20:76:65:72:73:69:6f:6e:20:31:2e:31:0a

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:33:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:57:41:52:4e:49:4e:47:5d:20:2a:2a:2a:2a:20:4e
00000030                                                   4f:54:20:45:4e:4f:55:47:48:20:52:41:4d:21:0a

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:83:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:57:41:52:4e:49:4e:47:5d:20:54:6f:20:73:74:61
00000030                                                   72:74:20:74:68:65:20:73:65:72:76:65:72:20:77:69
00000040                                                   74:68:20:6d:6f:72:65:20:72:61:6d:2c:20:6c:61:75
00000050                                                   6e:63:68:20:69:74:20:61:73:20:22:6a:61:76:61:20
00000060                                                   2d:58:6d:78:31:30:32:34:4d:20:2d:58:6d:73:31:30
00000070                                                   32:34:4d:20:2d:6a:61:72:20:6d:69:6e:65:63:72:61
00000080                                                   66:74:5f:73:65:72:76:65:72:2e:6a:61:72:22:0a

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:2e:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:49:4e:46:4f:5d:20:4c:6f:61:64:69:6e:67:20:70
00000030                                                   72:6f:70:65:72:74:69:65:73:0a

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:4c:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:49:4e:46:4f:5d:20:53:74:61:72:74:69:6e:67:20
00000030                                                   4d:69:6e:65:63:72:61:66:74:20:73:65:72:76:65:72
00000040                                                   20:6f:6e:20:31:37:36:2e:33:31:2e:31:30:30:2e:38
00000050                                                   30:3a:32:35:35:37:34:0a

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:3b:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:57:41:52:4e:49:4e:47:5d:20:2a:2a:2a:2a:20:46
00000030                                                   41:49:4c:45:44:20:54:4f:20:42:49:4e:44:20:54:4f
00000040                                                   20:50:4f:52:54:21:0a

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:60:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:57:41:52:4e:49:4e:47:5d:20:54:68:65:20:65:78
00000030                                                   63:65:70:74:69:6f:6e:20:77:61:73:3a:20:6a:61:76
00000040                                                   61:2e:6e:65:74:2e:42:69:6e:64:45:78:63:65:70:74
00000050                                                   69:6f:6e:3a:20:41:64:64:72:65:73:73:20:61:6c:72
00000060                                                   65:61:64:79:20:69:6e:20:75:73:65:0a

<- NET_SSH2_MSG_CHANNEL_EXTENDED_DATA (0s)
00000000                                                   00:00:00:00:00:00:00:01:00:00:00:50:32:30:31:32
00000010                                                   2d:30:33:2d:30:34:20:32:32:3a:32:33:3a:31:37:20
00000020                                                   5b:57:41:52:4e:49:4e:47:5d:20:50:65:72:68:61:70
00000030                                                   73:20:61:20:73:65:72:76:65:72:20:69:73:20:61:6c
00000040                                                   72:65:61:64:79:20:72:75:6e:6e:69:6e:67:20:6f:6e
00000050                                                   20:74:68:61:74:20:70:6f:72:74:3f:0a

-> NET_SSH2_MSG_CHANNEL_EOF (0s)
00000000                                                   00:00:00:00


I've used last SVN version from repo and still nothing gets better. Any further questions?
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby TerraFrost » Mon Mar 05, 2012 2:06 am

Try the latest SVN now!
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: tmux start in detach mode problem.

Postby ferus » Mon Mar 05, 2012 10:48 am

Hi,
works like a charm. I will test it within my application for few days and i will let you now.
Anyways i think we should consider working on that tmux new-session problem as well.

Edit: When i've plugged it in, i've got

Code: Select all
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: channel

Line Number: 2353


Any clue? I've switched of notices, script is working - but this must be like miss type or sth.
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby TerraFrost » Mon Mar 05, 2012 3:33 pm

The latest SVN fixes the PHP notices.

Anyways i think we should consider working on that tmux new-session problem as well.

I'm not sure what this problem is?
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: tmux start in detach mode problem.

Postby ferus » Tue Mar 06, 2012 11:26 am

Thanks for your help, you've saved my project.

About your question - i thought that setTimeout() is just temporary solution - users in future may have similar problem and they don't want to use setTimeout() all the time.
ferus
Traveler
 
Posts: 10
Joined: Sun Feb 05, 2012 10:41 am

Re: tmux start in detach mode problem.

Postby TerraFrost » Tue Mar 06, 2012 2:17 pm

ferus wrote:Thanks for your help, you've saved my project.

About your question - i thought that setTimeout() is just temporary solution - users in future may have similar problem and they don't want to use setTimeout() all the time.

I was going to say that exit-status NET_SSH2_MSG_CHANNEL_REQUEST's don't imply that the connection is going to be closed but, when I was going to quote the specs, it says "The channel needs to be closed with SSH_MSG_CHANNEL_CLOSE after this message." so I guess I was wrong lol. I'll update my code later today!
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Next

Return to phpseclib support

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron