Reputation: 6739
SSH2 connect isn't working with php although i am sure i install it on the server that i want to use to connect to the remote server
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (!($con = ssh2_connect("ip_goes here", 22))) {
die('<div style="color:#333;font-size:18px">Server not reachable.Error 1002 </div>');
}
echo "ssh2_connect finally works";
?>
I am getting Server not reachable.Error 1002
and Warning: ssh2_connect(): Unable to connect to ip_goes_here on port 22
Btw i tried to connect to the ip via port 22 using putty and it works just fine.If ssh2_connect
didn't exist i would get Undefined function error
EDIT I was able to connect to the ip via ssh fine
ssh [email protected]
The authenticity of host 'xxx.xx.xxx.xxx (xxx.xx.xxx.xxx)' can't be established.
RSA key fingerprint is 3a:8b:14:a8:10:09:0a:2f:1a:c4:3b:c7:97:56:42:6e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'xxx.xx.xxx.xxx' (RSA) to the list of known hosts.
Upvotes: 0
Views: 2065
Reputation: 6739
The issue was with selinux and i had to disable it for ssh2 to connect
Upvotes: 1