2014-12-21 47 views
0

SSH2連接不與PHP的工作工作,儘管我相信我,我要用來連接到遠程服務器的服務器上安裝它ssh2_connect不是用PHP

<?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"; 
    ?> 

我越來越Server not reachable.Error 1002Warning: ssh2_connect(): Unable to connect to ip_goes_here on port 22

順便說一句,我試圖通過端口使用膩子22連接到IP和它的作品只是fine.If ssh2_connect不存在我會得到Undefined function error

編輯 我能夠通過ssh精細

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. 
+0

也許Web服務器的IP從連接到SSH服務器阻塞。沒有更多的信息就很難調試這樣的問題。你能夠SSH入網絡服務器,並嘗試間接ssh到另一臺服務器? – Mike

+0

當你坐在網絡服務器上給你帶來麻煩時,'ssh user @'爲你工作嗎? – jww

+0

@jww我試過兩邊的ssh user @,它的工作很完美。參閱我的編輯 – user2650277

回答

1

的問題是在SELinux連接到IP,我不得不禁用它SSH2連接