Establishing a remote connection to run command with php exec

What I would like is to establish a remote connection to run command with php exec from server 1 to server 2.
I have been using this in php 5 but doesn’t work in php 7:(pure php)

include("Net/SSH2.php");
$ssh = new Net_SSH2('123.131.313.131');
if (!$ssh->login('root', '1313224')) {
    exit('');
}
$ssh->exec();
Methods with the same name as their class will not be constructors in a 
future version of PHP; Net_SSH2 has a deprecated constructor in

(after changing the function name, it still not working, variables are blank etc)

is there any solutions for pure PHP to do this

and there is the github

I have no idea how you can download the new files, only got the raw option. Anyways I tried getting the new github file, but I don’t get it working at all, what i didn’t get:

?????????
namespace phpseclib\Net;


new \phpseclib\Net\SSH2('www.domain.tld');

no class name is like that

if possible someone could help me to get this working or educate me, if I am too stpd to use this new class.

$ssh = new \phpseclib\Net\SSH2('123.131.313.131');
if (!$ssh->login('root', '1313224')) {
    exit('');
}

???

Big Thank You for any help you can give me!

1 Like

So I investigated this new GitHub version, to connect server A to server B, but this means I need to install (composer to my server), how can I do that in shared hosting(I can’t), If in PHP 5 that was possible why not PHP 7 the same way?

I know there are several options like that, but the no need to install was that made this special script. Shared hosting is used by humans too, so it would be nice.

Any scripts out there, without need to install for PHP 7?

Anyways I found a workaround too:
I need to make a different server with PHP 5, that’s a good idea if no other way to go…

If anyone has any useful information please feel free to post.

Thank you

Edit: seems like maybe there were something installed in these old PHP versions afterall.P who knows

Edit Again: WT!!! my server warnings about this script are changing in PHP or no warning at all… THIS IS SO STRANGE, I CAN’T BELIEVE MY EYES lol the server php messages just are so random, these not like errors but suggestions. PHP 7!

Leaving aside all the code, is this just not a security issue where the owner of the server is not allowing root logins from a remote server? Or was the account in your code just an example?

Example logins ofc,

I didn’t get the Not part but…I can explain without the not part, using the remote server:
it’s a good way to use a remote server as a “worker”, and connecting different servers is very useful, you can allocate working force from one to another and some servers need special programs etc, more resources, but at the end all the information is collected to the main server for the user.

As long as proper logins are used, note that some programs are only working correctly with root access, so there no other reasonable way, and the servers are logically located at the same provider.

Anyways, everything can be always improved endlessly(it’s a bit more complicated)., starting from the latest PHP version,

I hope that this answered your question(s).

Ah… and I got this working after ignoring PHP 7 suggestions, probably didn’t need to do anything.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.