For the sake of my explanation, keep the following im mind.
Machine 1 Internal = 127.0.0.1
Machine 1 External = 192.0.0.1
Machine 2 Internal = 127.0.0.2
Machime 2 External = 192.0.0.2
Client External = 10.0.0.1
So, I will try to connect to the internal IP of Machine #1, while on Machine #1:
$server = "127.0.0.1";
$conn = ssh2_connect($server, 22);
Results in [/var/log/httpd/error_log]:
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 127.0.0.1 on port 22 in /var/www/html/file.php on line 8
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 127.0.0.1 in /var/www/html/file.php on line 8
Changing the IP from internal to external yielded the same error.
Now, I will try to connect to the external IP of machine #1 while the PHP file is ran off of Machine #2's webserver:
$server = "192.0.0.1"
$conn = ssh2_connect($server);
Results in [/var/log/httpd/error_log]:
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 192.0.0.1 on port 22 in /var/www/html/file.php on line 8
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 192.0.0.1 in /var/www/html/file.php on line 8
All of this is the case, but oddly enough, if I run the exact code through the php -a
interpreter, and proceed to authenticate and run a command, all works flawlessly.
What is the issue??