2016-06-02 15 views
1

Mit Kitt kann ich verbinden. Aber mit PHP kann ich nicht. Ich weiß nicht, warum es passiert? Ich habe die Erweiterung ssh2 in PHP installiert und aktiviert.SSH-Verbindung funktioniert nicht in PHP

verwendete ich den folgenden Code: -

$ssh2 = ssh2_connect('myhost'); 
if (false === $ssh2) { 
die('connection failed'); 
} 
$auth = @ssh2_auth_password($ssh, "hostusername", "hostpassword"); 
if (false === $auth) { 
    die('authentication failed'); 
} 
echo ssh2_exec($ssh2,'pwd'); 

aber dies wird den folgenden Fehler: Warnung: ssh2_exec(): Anschluss nicht

Antwort

1

Sie einen Tippfehler authentifiziert haben. Ihre SSH-Authentifizierung ist für $ ssh, nicht für $ ssh2. (Linie 5)

0

Sie haben Typ für $ ssh, nicht SSH2 $ Linie 5.

muss Ihr Code sein

$ssh2 = ssh2_connect('myhost'); 
if (false === $ssh2) { 
die('connection failed'); 
} 
$auth = @ssh2_auth_password($ssh2, "hostusername", "hostpassword"); 
if (false === $auth) { 
    die('authentication failed'); 
} 
echo ssh2_exec($ssh2,'pwd');