Connection Speed. anyway to get a faster connection ?

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.

Connection Speed. anyway to get a faster connection ?

Postby ramon » Tue Jul 03, 2012 3:22 pm

Hi
New user only found this site today :)
I've just started using this for ssh access into a web box where the php user can't run any local commands.
I've got the script below to work fine, but it seems very slow to connect. 5 -10 seconds.

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

   $ssh = new Net_SSH2('127.0.0.1');
   if (!$ssh->login('root', 'password')) {
       exit('Login Failed');
   }

   echo $ssh->exec('pwd');
   echo $ssh->exec('ls -la');

   $ssh->disconnect();   unset($ssh);

?>


As this is running on the device it's going to ssh into is there anyway to speed it up ?
Thanks :)
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby TerraFrost » Wed Jul 04, 2012 3:33 pm

It's hard to say without seeing the logs.

The logs can be generated thusly:

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

define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');

echo $ssh->getLog();
?>

Note the define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX) and the $ssh->getLog() calls.

Thanks!
TerraFrost
Legendary Guard
 
Posts: 12217
Joined: Wed Dec 04, 2002 6:37 am

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Thu Jul 05, 2012 4:18 pm

Thanks for the reply.
Here is the log :

Code: Select all
<- 00000000 53:53:48:2d:32:2e:30:2d:64:72:6f:70:62:65:61:72 SSH-2.0-dropbear 00000010 5f:30:2e:34:38:0d:0a _0.48.. -> 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.0013s) 00000000 f7:0a:bc:44:1d:19:91:51:5f:0b:c4:58:87:3d:57:d6 ...D...Q_..X.=W. 00000010 00:00:00:1a:64:69:66:66:69:65:2d:68:65:6c:6c:6d ....diffie-hellm 00000020 61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:00:00 an-group1-sha1.. 00000030 00:0f:73:73:68:2d:72:73:61:2c:73:73:68:2d:64:73 ..ssh-rsa,ssh-ds 00000040 73:00:00:00:55:61:65:73:31:32:38:2d:63:62:63:2c s...Uaes128-cbc, 00000050 33:64:65:73:2d:63:62:63:2c:61:65:73:32:35:36:2d 3des-cbc,aes256- 00000060 63:62:63:2c:74:77:6f:66:69:73:68:32:35:36:2d:63 cbc,twofish256-c 00000070 62:63:2c:74:77:6f:66:69:73:68:2d:63:62:63:2c:74 bc,twofish-cbc,t 00000080 77:6f:66:69:73:68:31:32:38:2d:63:62:63:2c:62:6c wofish128-cbc,bl 00000090 6f:77:66:69:73:68:2d:63:62:63:00:00:00:55:61:65 owfish-cbc...Uae 000000a0 73:31:32:38:2d:63:62:63:2c:33:64:65:73:2d:63:62 s128-cbc,3des-cb 000000b0 63:2c:61:65:73:32:35:36:2d:63:62:63:2c:74:77:6f c,aes256-cbc,two 000000c0 66:69:73:68:32:35:36:2d:63:62:63:2c:74:77:6f:66 fish256-cbc,twof 000000d0 69:73:68:2d:63:62:63:2c:74:77:6f:66:69:73:68:31 ish-cbc,twofish1 000000e0 32:38:2d:63:62:63:2c:62:6c:6f:77:66:69:73:68:2d 28-cbc,blowfish- 000000f0 63:62:63:00:00:00:1f:68:6d:61:63:2d:73:68:61:31 cbc....hmac-sha1 00000100 2d:39:36:2c:68:6d:61:63:2d:73:68:61:31:2c:68:6d -96,hmac-sha1,hm 00000110 61:63:2d:6d:64:35:00:00:00:1f:68:6d:61:63:2d:73 ac-md5....hmac-s 00000120 68:61:31:2d:39:36:2c:68:6d:61:63:2d:73:68:61:31 ha1-96,hmac-sha1 00000130 2c:68:6d:61:63:2d:6d:64:35:00:00:00:09:7a:6c:69 ,hmac-md5....zli 00000140 62:2c:6e:6f:6e:65:00:00:00:09:7a:6c:69:62:2c:6e b,none....zlib,n 00000150 6f:6e:65:00:00:00:00:00:00:00:00:00:00:00:00:00 one............. -> NET_SSH2_MSG_KEXINIT (0.0001s) 00000000 5f:c2:d8:70:52:33:0a:32:8d:4b:1e:bb:d8:3f:58:b6 _..pR3.2.K...?X. 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:eb:e5:13:97:e8:eb:7b:b9:0b:7a:45 ...........{..zE 00000010 2c:97:b8:2b:e3:52:d1:85:91:51:71:f8:01:96:ec:6f ,..+.R...Qq....o 00000020 47:6a:66:66:46:9f:45:e3:1f:2f:7e:d4:f7:7d:53:73 GjffF.E../~..}Ss 00000030 8b:df:c6:7e:98:8f:f5:8c:9a:7f:70:7c:a2:dc:c7:29 ...~......p|...) 00000040 a5:6f:00:c2:96:e9:d2:a1:b0:3f:2c:b4:d4:bf:b0:24 .o.......?,....$ 00000050 db:27:3b:d3:d7:6d:06:a2:ae:3a:96:5f:ae:23:04:68 .';..m...:._.#.h 00000060 e6:c3:69:3d:9b:3f:8e:8d:b8:31:3e:35:9b:7e:1e:97 ..i=.?...1>5.~.. 00000070 8d:db:6e:70:92:e6:00:9f:f5:84:bf:30:40:63:e2:3b ..np.......0@c.; 00000080 5d:34:9d:d8:37 ]4..7 <- NET_SSH2_MSG_KEXDH_REPLY (0.3849s) 00000000 00:00:00:99:00:00:00:07:73:73:68:2d:72:73:61:00 ........ssh-rsa. 00000010 00:00:03:01:00:01:00:00:00:83:00:b7:88:d7:b8:91 ................ 00000020 77:0a:6e:c8:60:e4:c1:cb:ee:c0:c0:21:4d:68:e7:b2 w.n.`......!Mh.. 00000030 ea:f2:5a:08:9d:c0:a2:01:f5:7b:77:4a:e8:5d:3d:0b ..Z......{wJ.]=. 00000040 11:0f:0c:d8:b9:c7:e1:ed:d8:31:7e:90:2a:31:ba:40 .........1~.*1.@ 00000050 22:5c:4d:30:db:0d:46:6c:b0:06:e5:59:36:ef:e1:e4 "\M0..Fl...Y6... 00000060 ce:5d:78:6c:a4:79:e2:4f:8d:65:ee:43:fe:6e:f3:14 .]xl.y.O.e.C.n.. 00000070 93:c7:72:c6:8b:55:f5:da:c5:5e:e9:80:73:fb:c1:e0 ..r..U...^..s... 00000080 2f:b1:86:04:df:71:75:9b:9f:87:e5:f0:47:28:e4:1c /....qu.....G(.. 00000090 ac:9e:05:f3:b7:5d:71:a1:88:d3:80:02:eb:00:00:00 .....]q......... 000000a0 80:32:5d:12:04:26:da:31:79:88:b9:20:d8:db:2b:cf .2]..&.1y.. ..+. 000000b0 bb:68:1f:62:8d:f8:61:e8:bb:6d:3e:b6:95:dd:ec:e6 .h.b..a..m>..... 000000c0 f5:54:b8:cc:7d:da:c5:89:d6:5d:94:c4:fc:2d:d8:f3 .T..}....]...-.. 000000d0 17:2b:08:20:a8:86:d8:89:db:4e:91:4e:f2:8a:5f:33 .+. .....N.N.._3 000000e0 98:70:2d:d4:ed:4f:5d:ab:55:9d:0e:b8:ac:e4:d6:24 .p-..O].U......$ 000000f0 8a:45:16:a4:46:7d:16:e5:f5:78:a6:8c:e1:b9:0f:fb .E..F}...x...... 00000100 00:f7:c1:bb:2d:c4:f1:f3:80:53:19:18:7a:3d:61:8f ....-....S..z=a. 00000110 3c:06:9a:0f:6f:a3:2b:7d:70:b9:02:7e:ef:a0:0b:67 ....o.+}p..~...g 00000120 60:00:00:00:91:00:00:00:07:73:73:68:2d:72:73:61 `........ssh-rsa 00000130 00:00:00:82:a2:52:68:6c:5b:28:13:30:2c:b9:c5:36 .....Rhl[(.0,..6 00000140 c4:4f:48:3d:99:b1:fd:29:b6:13:74:16:ad:84:22:ed .OH=...)..t...". 00000150 5e:fb:58:51:a7:12:1f:ba:63:cd:ed:c4:bd:f4:93:d3 ^.XQ....c....... 00000160 62:71:03:8a:20:ea:e7:ab:56:de:ce:7f:86:d6:3e:84 bq.. ...V.....>. 00000170 f4:ce:0d:65:c6:3f:fd:92:b5:00:55:73:43:08:20:44 ...e.?....UsC. D 00000180 df:b8:77:79:3a:55:b2:6c:4b:7d:c1:3a:11:85:da:e8 ..wy:U.lK}.:.... 00000190 ae:fd:af:c4:34:a2:c5:7a:66:45:3e:c0:8b:63:f5:42 ....4..zfE>..c.B 000001a0 7f:cf:ba:b4:bf:2c:ec:6e:92:7c:d3:c7:77:65:38:42 .....,.n.|..we8B 000001b0 ce:81:6b:56:19:0f ..kV.. -> NET_SSH2_MSG_NEWKEYS (0.0001s) <- NET_SSH2_MSG_NEWKEYS (0.0009s) -> NET_SSH2_MSG_SERVICE_REQUEST (0.0001s) 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.0008s) 00000000 00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68 ....ssh-userauth -> NET_SSH2_MSG_USERAUTH_REQUEST (0s) 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 (0.01s) -> NET_SSH2_MSG_CHANNEL_OPEN (0.0001s) 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.0008s) 00000000 00:00:00:00:00:00:00:00:00:00:1f:40:00:00:1f:40 ...........@...@ -> 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 1a:63:70:20:2f:66:74:70:2f:74:68:61:6e:6b:79:6f .cp /ftp/thankyo 00000020 75:2e:77:61:76:20:2f:57:65:62:2f u.wav /Web/ <- NET_SSH2_MSG_CHANNEL_SUCCESS (0.0074s) 00000000 00:00:00:00 .... <- NET_SSH2_MSG_CHANNEL_EOF (0.2s) 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_EOF (0.0001s) 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 ....
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Thu Jul 05, 2012 8:23 pm

NET_SSH2_MSG_KEXDH_REPLY (0.3849s)

Is that nearly 4 seconds ? because what the delay seems to be about 4 seconds.
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby TerraFrost » Sat Jul 07, 2012 10:32 pm

It's a little less than half a second.

None of the packets seem to take that much time to send / receive a response. My guess would be that it's the diffie-hellman key exchange that's taking a while. You could do this to verify:

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

define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

$start = microtime(true);
$ssh = new Net_SSH2('www.domain.tld');
$elapsed = microtime(true) - $start;
echo "took $elapsed seconds<br>";
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');

echo $ssh->getLog();
?>
If that is indeed what's slowing things down... there's not a ton that can be done about that. If you can install extensions installing the gmp extension would speed things up. Depending on the version of PHP you're running it might also be faster to use the pure-PHP biginteger implementation. ie. do define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL) after including Net/SSH2.php but before initializing the Net_SSH2 object.
TerraFrost
Legendary Guard
 
Posts: 12217
Joined: Wed Dec 04, 2002 6:37 am

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Sun Jul 08, 2012 7:07 am

He's the result of the test..

Code: Select all
took -0.540488 seconds
/root drwxr-xr-x 3 root root 4096 Apr 11 12:46 . drwxr-xr-x 27 root root 4096 May 18 12:21 .. -rw-r--r-- 1 root root 203 Apr 27 14:50 .profile -rw-r--r-- 1 root root 203 Apr 27 14:35 .profile_old drwx------ 2 root root 4096 Feb 27 15:38 .ssh -rw-r--r-- 1 root root 1415 Jul 1 01:11 dead.letter <- 00000000 53:53:48:2d:32:2e:30:2d:64:72:6f:70:62:65:61:72 SSH-2.0-dropbear 00000010 5f:30:2e:34:38:0d:0a _0.48.. -> 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:0d:0a b_0.2.. <- NET_SSH2_MSG_KEXINIT (0.0011s) 00000000 63:d8:f2:f2:7f:40:73:aa:af:66:af:e9:cb:e7:42:a7 c....@s..f....B. 00000010 00:00:00:1a:64:69:66:66:69:65:2d:68:65:6c:6c:6d ....diffie-hellm 00000020 61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:00:00 an-group1-sha1.. 00000030 00:0f:73:73:68:2d:72:73:61:2c:73:73:68:2d:64:73 ..ssh-rsa,ssh-ds 00000040 73:00:00:00:55:61:65:73:31:32:38:2d:63:62:63:2c s...Uaes128-cbc, 00000050 33:64:65:73:2d:63:62:63:2c:61:65:73:32:35:36:2d 3des-cbc,aes256- 00000060 63:62:63:2c:74:77:6f:66:69:73:68:32:35:36:2d:63 cbc,twofish256-c 00000070 62:63:2c:74:77:6f:66:69:73:68:2d:63:62:63:2c:74 bc,twofish-cbc,t 00000080 77:6f:66:69:73:68:31:32:38:2d:63:62:63:2c:62:6c wofish128-cbc,bl 00000090 6f:77:66:69:73:68:2d:63:62:63:00:00:00:55:61:65 owfish-cbc...Uae 000000a0 73:31:32:38:2d:63:62:63:2c:33:64:65:73:2d:63:62 s128-cbc,3des-cb 000000b0 63:2c:61:65:73:32:35:36:2d:63:62:63:2c:74:77:6f c,aes256-cbc,two 000000c0 66:69:73:68:32:35:36:2d:63:62:63:2c:74:77:6f:66 fish256-cbc,twof 000000d0 69:73:68:2d:63:62:63:2c:74:77:6f:66:69:73:68:31 ish-cbc,twofish1 000000e0 32:38:2d:63:62:63:2c:62:6c:6f:77:66:69:73:68:2d 28-cbc,blowfish- 000000f0 63:62:63:00:00:00:1f:68:6d:61:63:2d:73:68:61:31 cbc....hmac-sha1 00000100 2d:39:36:2c:68:6d:61:63:2d:73:68:61:31:2c:68:6d -96,hmac-sha1,hm 00000110 61:63:2d:6d:64:35:00:00:00:1f:68:6d:61:63:2d:73 ac-md5....hmac-s 00000120 68:61:31:2d:39:36:2c:68:6d:61:63:2d:73:68:61:31 ha1-96,hmac-sha1 00000130 2c:68:6d:61:63:2d:6d:64:35:00:00:00:09:7a:6c:69 ,hmac-md5....zli 00000140 62:2c:6e:6f:6e:65:00:00:00:09:7a:6c:69:62:2c:6e b,none....zlib,n 00000150 6f:6e:65:00:00:00:00:00:00:00:00:00:00:00:00:00 one............. -> NET_SSH2_MSG_KEXINIT (0.0006s) 00000000 5e:4d:1f:5d:c0:aa:27:b4:c7:52:9a:cf:ee:96:80:15 ^M.]..'..R...... 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.3836s) 00000000 00:00:00:81:00:8c:23:0a:d8:d6:f7:5f:d9:a6:38:23 ......#...._..8# 00000010 d0:ff:cb:bd:e7:d3:fb:27:e2:09:03:9a:3b:6b:e6:a8 .......'....;k.. 00000020 9e:0e:48:9f:bd:fc:10:db:bb:cc:99:b6:81:d8:52:6c ..H...........Rl 00000030 70:c7:9d:17:a4:a7:e7:6a:3f:55:46:79:d2:c4:41:12 p......j?UFy..A. 00000040 ec:cb:eb:91:49:7c:65:95:8e:32:4f:b1:63:97:36:a0 ....I|e..2O.c.6. 00000050 6c:f9:bb:00:86:07:6c:b7:fc:9d:e4:9f:95:da:46:fc l.....l.......F. 00000060 d7:7a:d1:2a:d6:3c:68:7a:9f:ea:27:6e:98:68:3f:bb .z.*..hz..'n.h?. 00000070 3e:09:85:1c:18:9d:65:01:5f:9a:10:9c:ac:88:c5:aa >.....e._....... 00000080 bc:44:8c:4b:7a .D.Kz <- NET_SSH2_MSG_KEXDH_REPLY (0.0001s) 00000000 00:00:00:99:00:00:00:07:73:73:68:2d:72:73:61:00 ........ssh-rsa. 00000010 00:00:03:01:00:01:00:00:00:83:00:b7:88:d7:b8:91 ................ 00000020 77:0a:6e:c8:60:e4:c1:cb:ee:c0:c0:21:4d:68:e7:b2 w.n.`......!Mh.. 00000030 ea:f2:5a:08:9d:c0:a2:01:f5:7b:77:4a:e8:5d:3d:0b ..Z......{wJ.]=. 00000040 11:0f:0c:d8:b9:c7:e1:ed:d8:31:7e:90:2a:31:ba:40 .........1~.*1.@ 00000050 22:5c:4d:30:db:0d:46:6c:b0:06:e5:59:36:ef:e1:e4 "\M0..Fl...Y6... 00000060 ce:5d:78:6c:a4:79:e2:4f:8d:65:ee:43:fe:6e:f3:14 .]xl.y.O.e.C.n.. 00000070 93:c7:72:c6:8b:55:f5:da:c5:5e:e9:80:73:fb:c1:e0 ..r..U...^..s... 00000080 2f:b1:86:04:df:71:75:9b:9f:87:e5:f0:47:28:e4:1c /....qu.....G(.. 00000090 ac:9e:05:f3:b7:5d:71:a1:88:d3:80:02:eb:00:00:00 .....]q......... 000000a0 81:00:f9:d7:6a:1c:d4:50:ed:fd:5e:56:9f:b1:9a:3a ....j..P..^V...: 000000b0 60:66:87:40:fa:f6:32:36:16:f5:cc:79:22:76:50:5c `f.@..26...y"vP\ 000000c0 29:b1:00:fd:cd:23:c1:77:fa:2e:4f:9f:5f:fb:d5:42 )....#.w..O._..B 000000d0 56:85:ff:dd:41:58:f9:0f:aa:57:e2:74:c3:28:4e:e7 V...AX...W.t.(N. 000000e0 f1:09:eb:db:37:0d:7b:c2:f8:e7:5c:78:8b:d4:20:d8 ....7.{...\x.. . 000000f0 80:3b:66:08:49:8f:50:64:41:2f:c7:57:14:be:04:85 .;f.I.PdA/.W.... 00000100 8c:84:1f:89:3c:3b:2b:c8:5a:96:1a:5c:74:e3:08:39 .....;+.Z..\t..9 00000110 2e:df:25:de:af:5c:b5:7a:e1:de:34:5b:77:6d:cc:46 ..%..\.z..4[wm.F 00000120 fe:c7:00:00:00:91:00:00:00:07:73:73:68:2d:72:73 ..........ssh-rs 00000130 61:00:00:00:82:a0:ab:91:ba:d4:ba:c3:1a:fc:1a:94 a............... 00000140 45:fd:2f:47:44:a9:c0:22:db:f9:87:7d:11:fe:28:40 E./GD.."...}..(@ 00000150 1f:b2:fe:81:cc:69:41:97:6f:e4:d9:1f:86:09:7d:3d .....iA.o.....}= 00000160 1b:96:5c:86:40:5e:84:da:ad:3d:d0:a2:d8:78:dc:ec ..\.@^...=...x.. 00000170 a0:28:4f:e0:4c:18:a6:9f:61:72:f4:57:a2:66:d4:59 .(O.L...ar.W.f.Y 00000180 de:ed:08:2d:a9:bb:7c:c3:25:ba:3f:36:a9:d4:0f:c4 ...-..|.%.?6.... 00000190 69:66:74:df:8e:dc:ec:25:df:6b:83:5c:dd:90:f1:2b ift....%.k.\...+ 000001a0 ce:d9:5c:74:38:6e:c8:96:5e:26:6d:fb:d5:61:4f:ce ..\t8n..^&m..aO. 000001b0 de:c8:54:b0:53:93:54 ..T.S.T -> NET_SSH2_MSG_NEWKEYS (0.0011s) <- NET_SSH2_MSG_NEWKEYS (0.0001s) -> NET_SSH2_MSG_SERVICE_REQUEST (0.0013s) 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.0001s) 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.011s) 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 (0.0001s) -> NET_SSH2_MSG_CHANNEL_OPEN (0.0012s) 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.0001s) 00000000 00:00:00:00:00:00:00:00:00:00:1f:40:00:00:1f:40 ...........@...@ -> NET_SSH2_MSG_CHANNEL_REQUEST (0.0035s) 00000000 00:00:00:00:00:00:00:04:65:78:65:63:01:00:00:00 ........exec.... 00000010 03:70:77:64 .pwd <- NET_SSH2_MSG_CHANNEL_SUCCESS (0.0001s) 00000000 00:00:00:00 .... <- NET_SSH2_MSG_CHANNEL_DATA (0.0508s) 00000000 00:00:00:00:00:00:00:06:2f:72:6f:6f:74:0a ......../root. <- NET_SSH2_MSG_CHANNEL_EOF (0.0001s) 00000000 00:00:00:00 .... <- NET_SSH2_MSG_CHANNEL_REQUEST (0.0001s) 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 (0.0001s) 00000000 00:00:00:00 .... -> NET_SSH2_MSG_CHANNEL_CLOSE (0.0005s) 00000000 00:00:00:00 .... -> NET_SSH2_MSG_CHANNEL_OPEN (0.0002s) 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.0287s) 00000000 00:00:00:00:00:00:00:00:00:00:1f:40:00:00:1f:40 ...........@...@ -> NET_SSH2_MSG_CHANNEL_REQUEST (0.021s) 00000000 00:00:00:00:00:00:00:04:65:78:65:63:01:00:00:00 ........exec.... 00000010 06:6c:73:20:2d:6c:61 .ls -la <- NET_SSH2_MSG_CHANNEL_SUCCESS (0.0001s) 00000000 00:00:00:00 .... <- NET_SSH2_MSG_CHANNEL_DATA (0.0146s) 00000000 00:00:00:00:00:00:01:7c:64:72:77:78:72:2d:78:72 .......|drwxr-xr 00000010 2d:78:20:20:20:20:33:20:72:6f:6f:74:20:20:20:20 -x 3 root 00000020 20:72:6f:6f:74:20:20:20:20:20:20:20:20:20:34:30 root 40 00000030 39:36:20:41:70:72:20:31:31:20:31:32:3a:34:36:20 96 Apr 11 12:46 00000040 2e:0a:64:72:77:78:72:2d:78:72:2d:78:20:20:20:32 ..drwxr-xr-x 2 00000050 37:20:72:6f:6f:74:20:20:20:20:20:72:6f:6f:74:20 7 root root 00000060 20:20:20:20:20:20:20:20:34:30:39:36:20:4d:61:79 4096 May 00000070 20:31:38:20:31:32:3a:32:31:20:2e:2e:0a:2d:72:77 18 12:21 ...-rw 00000080 2d:72:2d:2d:72:2d:2d:20:20:20:20:31:20:72:6f:6f -r--r-- 1 roo 00000090 74:20:20:20:20:20:72:6f:6f:74:20:20:20:20:20:20 t root 000000a0 20:20:20:20:32:30:33:20:41:70:72:20:32:37:20:31 203 Apr 27 1 000000b0 34:3a:35:30:20:2e:70:72:6f:66:69:6c:65:0a:2d:72 4:50 .profile.-r 000000c0 77:2d:72:2d:2d:72:2d:2d:20:20:20:20:31:20:72:6f w-r--r-- 1 ro 000000d0 6f:74:20:20:20:20:20:72:6f:6f:74:20:20:20:20:20 ot root 000000e0 20:20:20:20:20:32:30:33:20:41:70:72:20:32:37:20 203 Apr 27 000000f0 31:34:3a:33:35:20:2e:70:72:6f:66:69:6c:65:5f:6f 14:35 .profile_o 00000100 6c:64:0a:64:72:77:78:2d:2d:2d:2d:2d:2d:20:20:20 ld.drwx------ 00000110 20:32:20:72:6f:6f:74:20:20:20:20:20:72:6f:6f:74 2 root root 00000120 20:20:20:20:20:20:20:20:20:34:30:39:36:20:46:65 4096 Fe 00000130 62:20:32:37:20:31:35:3a:33:38:20:2e:73:73:68:0a b 27 15:38 .ssh. 00000140 2d:72:77:2d:72:2d:2d:72:2d:2d:20:20:20:20:31:20 -rw-r--r-- 1 00000150 72:6f:6f:74:20:20:20:20:20:72:6f:6f:74:20:20:20 root root 00000160 20:20:20:20:20:20:31:34:31:35:20:4a:75:6c:20:20 1415 Jul 00000170 31:20:30:31:3a:31:31:20:64:65:61:64:2e:6c:65:74 1 01:11 dead.let 00000180 74:65:72:0a ter. <- NET_SSH2_MSG_CHANNEL_EOF (0.0001s) 00000000 00:00:00:00 .... <- NET_SSH2_MSG_CHANNEL_REQUEST (0.0001s) 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 (0.0001s) 00000000 00:00:00:00 .... -> NET_SSH2_MSG_CHANNEL_CLOSE (0.0005s) 00000000 00:00:00:00 ....


Does that show anything ?
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Sun Jul 08, 2012 7:22 am

I've tried adding define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);

that doesn't help ! any other option ?
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby TerraFrost » Sun Jul 08, 2012 2:54 pm

Can you do this?:

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

define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

$start = microtime(true);
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}
$elapsed = microtime(true) - $start;
echo "took $elapsed seconds<br>";

   echo $ssh->exec('pwd');
   echo $ssh->exec('ls -la');

   $ssh->disconnect();   unset($ssh);

ie. move the $elapsed thing to after the $ssh->login().

Also, if you could start putting <pre> tags around your logs that'd be great. Thanks!
TerraFrost
Legendary Guard
 
Posts: 12217
Joined: Wed Dec 04, 2002 6:37 am

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Sun Jul 08, 2012 3:39 pm

new log:

Code: Select all
took 0.28918 seconds
/root drwxr-xr-x 3 root root 4096 Apr 11 12:46 . drwxr-xr-x 27 root root 4096 May 18 12:21 .. -rw-r--r-- 1 root root 203 Apr 27 14:50 .profile -rw-r--r-- 1 root root 203 Apr 27 14:35 .profile_old drwx------ 2 root root 4096 Feb 27 15:38 .ssh -rw-r--r-- 1 root root 1415 Jul 1 01:11 dead.letter
<-
00000000  53:53:48:2d:32:2e:30:2d:64:72:6f:70:62:65:61:72  SSH-2.0-dropbear
00000010  5f:30:2e:34:38:0d:0a                             _0.48..

->
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:0d:0a                             b_0.2..

<- NET_SSH2_MSG_KEXINIT (0.0001s)
00000000  56:6e:00:41:f9:3c:3c:5b:ae:95:26:8a:e1:be:29:cd  Vn.A...[..&...).
00000010  00:00:00:1a:64:69:66:66:69:65:2d:68:65:6c:6c:6d  ....diffie-hellm
00000020  61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:00:00  an-group1-sha1..
00000030  00:0f:73:73:68:2d:72:73:61:2c:73:73:68:2d:64:73  ..ssh-rsa,ssh-ds
00000040  73:00:00:00:55:61:65:73:31:32:38:2d:63:62:63:2c  s...Uaes128-cbc,
00000050  33:64:65:73:2d:63:62:63:2c:61:65:73:32:35:36:2d  3des-cbc,aes256-
00000060  63:62:63:2c:74:77:6f:66:69:73:68:32:35:36:2d:63  cbc,twofish256-c
00000070  62:63:2c:74:77:6f:66:69:73:68:2d:63:62:63:2c:74  bc,twofish-cbc,t
00000080  77:6f:66:69:73:68:31:32:38:2d:63:62:63:2c:62:6c  wofish128-cbc,bl
00000090  6f:77:66:69:73:68:2d:63:62:63:00:00:00:55:61:65  owfish-cbc...Uae
000000a0  73:31:32:38:2d:63:62:63:2c:33:64:65:73:2d:63:62  s128-cbc,3des-cb
000000b0  63:2c:61:65:73:32:35:36:2d:63:62:63:2c:74:77:6f  c,aes256-cbc,two
000000c0  66:69:73:68:32:35:36:2d:63:62:63:2c:74:77:6f:66  fish256-cbc,twof
000000d0  69:73:68:2d:63:62:63:2c:74:77:6f:66:69:73:68:31  ish-cbc,twofish1
000000e0  32:38:2d:63:62:63:2c:62:6c:6f:77:66:69:73:68:2d  28-cbc,blowfish-
000000f0  63:62:63:00:00:00:1f:68:6d:61:63:2d:73:68:61:31  cbc....hmac-sha1
00000100  2d:39:36:2c:68:6d:61:63:2d:73:68:61:31:2c:68:6d  -96,hmac-sha1,hm
00000110  61:63:2d:6d:64:35:00:00:00:1f:68:6d:61:63:2d:73  ac-md5....hmac-s
00000120  68:61:31:2d:39:36:2c:68:6d:61:63:2d:73:68:61:31  ha1-96,hmac-sha1
00000130  2c:68:6d:61:63:2d:6d:64:35:00:00:00:09:7a:6c:69  ,hmac-md5....zli
00000140  62:2c:6e:6f:6e:65:00:00:00:09:7a:6c:69:62:2c:6e  b,none....zlib,n
00000150  6f:6e:65:00:00:00:00:00:00:00:00:00:00:00:00:00  one.............

-> NET_SSH2_MSG_KEXINIT (0.0006s)
00000000  de:7c:5d:67:b5:e3:02:7a:e1:fd:47:51:55:c0:b0:ab  .|]g...z..GQU...
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.387s)
00000000  00:00:00:80:77:68:76:92:15:dd:19:1c:e9:71:aa:c2  ....whv......q..
00000010  b0:52:ea:67:61:60:6f:16:94:28:4f:49:5c:d7:e2:23  .R.ga`o..(OI\..#
00000020  a0:40:fd:b2:cb:d9:8c:71:4a:ec:5b:10:65:a5:f0:4d  .@.....qJ.[.e..M
00000030  b7:05:12:04:37:64:3e:e3:e3:6f:17:65:bc:31:4d:ac  ....7d>..o.e.1M.
00000040  0b:4f:b8:19:ed:de:76:9d:e3:54:a5:64:18:d6:56:4d  .O....v..T.d..VM
00000050  83:73:11:a0:62:2f:42:22:88:2e:31:d8:7d:e1:42:fb  .s..b/B"..1.}.B.
00000060  00:b7:25:63:eb:7d:47:cf:3d:ea:45:47:e8:4b:b4:5e  ..%c.}G.=.EG.K.^
00000070  d6:88:56:4f:0f:ef:92:2f:57:1b:9b:a4:ce:0f:0a:4e  ..VO.../W......N
00000080  f3:ba:72:fb                                      ..r.

<- NET_SSH2_MSG_KEXDH_REPLY (0.0001s)
00000000  00:00:00:99:00:00:00:07:73:73:68:2d:72:73:61:00  ........ssh-rsa.
00000010  00:00:03:01:00:01:00:00:00:83:00:b7:88:d7:b8:91  ................
00000020  77:0a:6e:c8:60:e4:c1:cb:ee:c0:c0:21:4d:68:e7:b2  w.n.`......!Mh..
00000030  ea:f2:5a:08:9d:c0:a2:01:f5:7b:77:4a:e8:5d:3d:0b  ..Z......{wJ.]=.
00000040  11:0f:0c:d8:b9:c7:e1:ed:d8:31:7e:90:2a:31:ba:40  .........1~.*1.@
00000050  22:5c:4d:30:db:0d:46:6c:b0:06:e5:59:36:ef:e1:e4  "\M0..Fl...Y6...
00000060  ce:5d:78:6c:a4:79:e2:4f:8d:65:ee:43:fe:6e:f3:14  .]xl.y.O.e.C.n..
00000070  93:c7:72:c6:8b:55:f5:da:c5:5e:e9:80:73:fb:c1:e0  ..r..U...^..s...
00000080  2f:b1:86:04:df:71:75:9b:9f:87:e5:f0:47:28:e4:1c  /....qu.....G(..
00000090  ac:9e:05:f3:b7:5d:71:a1:88:d3:80:02:eb:00:00:00  .....]q.........
000000a0  80:4d:dc:62:8c:6d:d4:a5:db:a1:62:a3:4b:81:7a:d9  .M.b.m....b.K.z.
000000b0  cd:8b:fd:f0:e4:c6:ab:01:08:4e:cc:56:bd:e2:c1:15  .........N.V....
000000c0  d3:f6:b3:e3:26:21:44:85:06:94:3c:51:54:c6:3c:1e  ....&!D....QT...
000000d0  ad:77:93:3e:83:61:d6:5e:86:3d:44:54:07:4e:55:bd  .w.>.a.^.=DT.NU.
000000e0  8f:d3:d4:36:cd:72:48:d7:c3:b8:c5:4f:14:95:6c:f3  ...6.rH....O..l.
000000f0  e2:35:16:cf:60:bd:d5:30:79:4b:3c:d0:bf:45:1e:f3  .5..`..0yK...E..
00000100  86:a9:d3:58:9e:96:19:32:37:94:54:48:ff:c4:2d:f4  ...X...27.TH..-.
00000110  cf:8c:d1:86:01:e1:4b:ef:2b:0a:45:25:d9:77:a5:55  ......K.+.E%.w.U
00000120  72:00:00:00:91:00:00:00:07:73:73:68:2d:72:73:61  r........ssh-rsa
00000130  00:00:00:82:13:c2:9c:4a:c2:8f:db:fd:1b:28:d7:a1  .......J.....(..
00000140  12:16:22:26:dc:ad:02:26:18:f9:a9:ec:29:f5:c5:26  .."&...&....)..&
00000150  59:e7:e4:9d:fd:af:33:c9:9b:8a:f1:cd:8b:8a:4f:fc  Y.....3.......O.
00000160  d3:63:fa:65:ca:89:0f:40:3e:0c:c1:28:e6:b2:d6:51  .c.e...@>..(...Q
00000170  30:a2:26:f6:c5:de:a2:df:b1:6f:0a:2f:09:a5:1d:84  0.&......o./....
00000180  a2:16:32:9f:a2:a7:f6:54:b2:18:c6:fe:4e:4d:f6:fa  ..2....T....NM..
00000190  0e:0e:e9:6c:0b:d5:07:cd:ad:2c:ec:d1:ac:98:83:e9  ...l.....,......
000001a0  cb:df:8f:7f:f9:52:95:fa:87:92:fd:0d:b2:6f:17:a3  .....R.......o..
000001b0  93:f3:be:a9:db:4b                                .....K

-> NET_SSH2_MSG_NEWKEYS (0.0011s)
                                                 

<- NET_SSH2_MSG_NEWKEYS (0.0001s)
                                                 

-> NET_SSH2_MSG_SERVICE_REQUEST (0.0013s)
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.0001s)
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.0102s)
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 (0.0001s)
                                                 

-> NET_SSH2_MSG_CHANNEL_OPEN (0.0012s)
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.0001s)
00000000  00:00:00:00:00:00:00:00:00:00:1f:40:00:00:1f:40  ...........@...@

-> NET_SSH2_MSG_CHANNEL_REQUEST (0.0149s)
00000000  00:00:00:00:00:00:00:04:65:78:65:63:01:00:00:00  ........exec....
00000010  03:70:77:64                                      .pwd

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

<- NET_SSH2_MSG_CHANNEL_DATA (0.022s)
00000000  00:00:00:00:00:00:00:06:2f:72:6f:6f:74:0a        ......../root.

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

<- NET_SSH2_MSG_CHANNEL_REQUEST (0.0001s)
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 (0.0001s)
00000000  00:00:00:00                                      ....

-> NET_SSH2_MSG_CHANNEL_CLOSE (0.0005s)
00000000  00:00:00:00                                      ....

-> NET_SSH2_MSG_CHANNEL_OPEN (0.0002s)
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.0272s)
00000000  00:00:00:00:00:00:00:00:00:00:1f:40:00:00:1f:40  ...........@...@

-> NET_SSH2_MSG_CHANNEL_REQUEST (0.0219s)
00000000  00:00:00:00:00:00:00:04:65:78:65:63:01:00:00:00  ........exec....
00000010  06:6c:73:20:2d:6c:61                             .ls -la

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

<- NET_SSH2_MSG_CHANNEL_DATA (0.0169s)
00000000  00:00:00:00:00:00:01:7c:64:72:77:78:72:2d:78:72  .......|drwxr-xr
00000010  2d:78:20:20:20:20:33:20:72:6f:6f:74:20:20:20:20  -x    3 root   
00000020  20:72:6f:6f:74:20:20:20:20:20:20:20:20:20:34:30   root         40
00000030  39:36:20:41:70:72:20:31:31:20:31:32:3a:34:36:20  96 Apr 11 12:46
00000040  2e:0a:64:72:77:78:72:2d:78:72:2d:78:20:20:20:32  ..drwxr-xr-x   2
00000050  37:20:72:6f:6f:74:20:20:20:20:20:72:6f:6f:74:20  7 root     root
00000060  20:20:20:20:20:20:20:20:34:30:39:36:20:4d:61:79          4096 May
00000070  20:31:38:20:31:32:3a:32:31:20:2e:2e:0a:2d:72:77   18 12:21 ...-rw
00000080  2d:72:2d:2d:72:2d:2d:20:20:20:20:31:20:72:6f:6f  -r--r--    1 roo
00000090  74:20:20:20:20:20:72:6f:6f:74:20:20:20:20:20:20  t     root     
000000a0  20:20:20:20:32:30:33:20:41:70:72:20:32:37:20:31      203 Apr 27 1
000000b0  34:3a:35:30:20:2e:70:72:6f:66:69:6c:65:0a:2d:72  4:50 .profile.-r
000000c0  77:2d:72:2d:2d:72:2d:2d:20:20:20:20:31:20:72:6f  w-r--r--    1 ro
000000d0  6f:74:20:20:20:20:20:72:6f:6f:74:20:20:20:20:20  ot     root     
000000e0  20:20:20:20:20:32:30:33:20:41:70:72:20:32:37:20       203 Apr 27
000000f0  31:34:3a:33:35:20:2e:70:72:6f:66:69:6c:65:5f:6f  14:35 .profile_o
00000100  6c:64:0a:64:72:77:78:2d:2d:2d:2d:2d:2d:20:20:20  ld.drwx------   
00000110  20:32:20:72:6f:6f:74:20:20:20:20:20:72:6f:6f:74   2 root     root
00000120  20:20:20:20:20:20:20:20:20:34:30:39:36:20:46:65           4096 Fe
00000130  62:20:32:37:20:31:35:3a:33:38:20:2e:73:73:68:0a  b 27 15:38 .ssh.
00000140  2d:72:77:2d:72:2d:2d:72:2d:2d:20:20:20:20:31:20  -rw-r--r--    1
00000150  72:6f:6f:74:20:20:20:20:20:72:6f:6f:74:20:20:20  root     root   
00000160  20:20:20:20:20:20:31:34:31:35:20:4a:75:6c:20:20        1415 Jul 
00000170  31:20:30:31:3a:31:31:20:64:65:61:64:2e:6c:65:74  1 01:11 dead.let
00000180  74:65:72:0a                                      ter.

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

<- NET_SSH2_MSG_CHANNEL_REQUEST (0.0001s)
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 (0.0001s)
00000000  00:00:00:00                                      ....

-> NET_SSH2_MSG_CHANNEL_CLOSE (0.0005s)
00000000  00:00:00:00                                      ....


If I run the script from my web server connecting to the remote box the process takes the same amount of time.
If I connect using putty from my web server to the remote box the process is instant.

Thanks for your help :)
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby TerraFrost » Sun Jul 08, 2012 4:05 pm

What does this say?:

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

define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

$start = microtime(true);
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');

//echo $ssh->getLog();
$elapsed = microtime(true) - $start;
echo "<hr>took $elapsed seconds<br>";
?>

Basically, I'm just trying to figure out where the bottleneck is. Is there a specific line that's taking a long time or are all of them taking a long time?

Based on what you've posted thus far it doesn't seem that the first two lines take that much time at all. The constructor took half a second in one instance and in your latest attempt took about a quarter of a second. That's not quite instant, I suppose, but it's better than four seconds.

Also, given that your MATH_BIGINTEGER_MODE isn't MATH_BIGINTEGER_MODE_GMP it's not gonna be as fast as PuTTY no matter what. MATH_BIGINTEGER_MODE_INTERNAL is pure-PHP so it'll never be as fast as pre-compiled assembly and MATH_BIGINTEGER_MODE_BCMATH... well it's done in C and is compiled when it's being used but it's coded pretty badly. It wouldn't take much for any C / C++ implementation to outpace that one.
TerraFrost
Legendary Guard
 
Posts: 12217
Joined: Wed Dec 04, 2002 6:37 am

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Sun Jul 08, 2012 8:13 pm

This returns :
Code: Select all
/root drwxr-xr-x 3 root root 4096 Apr 11 12:46 . drwxr-xr-x 27 root root 4096 May 18 12:21 .. -rw-r--r-- 1 root root 203 Apr 27 14:50 .profile -rw-r--r-- 1 root root 203 Apr 27 14:35 .profile_old drwx------ 2 root root 4096 Feb 27 15:38 .ssh -rw-r--r-- 1 root root 1415 Jul 1 01:11 dead.letter
took 0.349203 seconds


But start to finish is 4 - 5 seconds.

It seems to be anything copying files between 2 folders, renaming a file etc.
Thanks for the help
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby TerraFrost » Sun Jul 08, 2012 8:20 pm

Can you post your full script? Or maybe you could isolate what the specific commands that are causing the slowdown and post them here? I can't really provide any assistance without that stuff!
TerraFrost
Legendary Guard
 
Posts: 12217
Joined: Wed Dec 04, 2002 6:37 am

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Thu Jul 12, 2012 8:51 pm

Hi
The last script I tried was this :

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

define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

$start = microtime(true);
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');

//echo $ssh->getLog();
$elapsed = microtime(true) - $start;
echo "<hr>took $elapsed seconds<br>";
?>


This test takes about 4 - 5 seconds to complete.. Not sure why it take so long for a simple script..
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby ramon » Thu Jul 12, 2012 8:52 pm

Just tried the same script with the exec lines rem'd out. Still takes about 4 -5 seconds..
ramon
Traveler
 
Posts: 13
Joined: Tue Jul 03, 2012 3:13 pm

Re: Connection Speed. anyway to get a faster connection ?

Postby TerraFrost » Sun Jul 15, 2012 12:28 am

So the script is saying "took 0.25 seconds" or whatever when in actuality the script is taking 4-5 seconds?

The only other lines that aren't being included in the benchmarking are these two:

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

define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);

If they're taking 4-5 seconds... then I'm curious... how long does this script take?:

Code: Select all
<?php
echo 'hello world!';
TerraFrost
Legendary Guard
 
Posts: 12217
Joined: Wed Dec 04, 2002 6:37 am

Next

Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 1 guest