RHEL から SLES マシンに ssh しようとしています。私はそれを達成するためにPHP関数ssh2を使用しています。正しいユーザー名とパスワードを渡した後でも、認証は行われません。しかし、RHEL->RHEL では同じコードが正常に機能します。RHEL ターミナルから SLES マシンに ssh できます。しかし、ssh2を使用すると、それは起こりません。
<?php
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
// log in at ip on port 22
if(!($con = ssh2_connect(ip, 22))){
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password password
if(!ssh2_auth_password($con, "root", "password")) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
if (!($stream = ssh2_exec($con, 'date' ))) {
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
//echo "in else";
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
echo $data;
fclose($stream);
}
}
}
?>
「失敗:認証できません」という出力が表示されます。なぜそのようなことが起こっているのですか?それに対する解決策はありますか?